久久99精品久久久久久琪琪,久久人人爽人人爽人人片亞洲,熟妇人妻无码中文字幕,亚洲精品无码久久久久久久

火車訂票系統(tǒng)部分 uml[推薦]

時(shí)間:2019-05-13 22:55:06下載本文作者:會員上傳
簡介:寫寫幫文庫小編為你整理了多篇相關(guān)的《火車訂票系統(tǒng)部分 uml[推薦]》,但愿對你工作學(xué)習(xí)有幫助,當(dāng)然你在寫寫幫文庫還可以找到更多《火車訂票系統(tǒng)部分 uml[推薦]》。

第一篇:火車訂票系統(tǒng)部分 uml[推薦]

全程一體化建模報(bào)告

——火車訂票系統(tǒng)

工商管理學(xué)院 信息1101 20110837 王若洲

1.火車訂票系統(tǒng)描述....................................................................3

2.用例圖和用例說明....................................................................3

3.類圖

........................................................................................11

4.對象圖......................................................................................13

5.順序圖和協(xié)作圖.....................................................................14

6.狀態(tài)圖....................................................................................28

7.組件圖.....................................................................................29

8.部署圖.....................................................................................30

9.總結(jié)............................................................................................301.火車訂票系統(tǒng)描述

線上預(yù)訂火車票系統(tǒng)是一款功能強(qiáng)大、操作簡便、易維護(hù)的、具有良好人機(jī)交互界面的線上訂票系統(tǒng),用戶可以在注冊之后進(jìn)入系統(tǒng)。購票用戶可以在系統(tǒng)中查詢車票信息,并進(jìn)行車票預(yù)定。同時(shí)購票用戶的個人信息可以修改,已預(yù)定的車票也可以在取消訂單的窗口中取消,很方便用戶的使用。

對于管理員來說,可以對用戶的信息進(jìn)行統(tǒng)一的管理,具有實(shí)時(shí)性、便捷性等有點(diǎn)。同時(shí),系統(tǒng)的數(shù)據(jù)可以定期備份,以防止信息的丟失。

2.用例圖和用例描述

2.1 用例描述

用例編號:001 用例名:注冊帳號

用例描述:購票用戶在注冊帳號后成為該系統(tǒng)的用戶,使用該系統(tǒng)的功能 參與者:購票用戶

前置條件:電子商城正常運(yùn)行

后置條件:如果用戶輸入的帳號在系統(tǒng)中未被注冊過,該用戶會注冊成功;否則,顯示帳號已注冊,提示用戶重新輸入。基本路徑:

1.用戶登錄火車訂票系統(tǒng)

2.購票用戶輸入要注冊的帳號和密碼 3.購票用戶提交信息

4.系統(tǒng)檢查用戶帳號是否已被注冊 5.系統(tǒng)添加帳號,并顯示注冊成功

擴(kuò)展點(diǎn):

4a:系統(tǒng)檢測到帳號已被注冊

4a1.用戶重新輸入 4a2.用戶離開系統(tǒng)

變異點(diǎn):無

用例編號:002 用例名:登錄帳號

用例描述:購票用戶在登錄帳號后進(jìn)入系統(tǒng),使用該系統(tǒng)的功能 參與者:購票用戶

前置條件:電子商城正常運(yùn)行

后置條件:如果用戶輸入的帳號和密碼與系統(tǒng)數(shù)據(jù)庫中的數(shù)據(jù)一致,該用戶會登錄成功;否則,顯示輸入信息有誤,提示用戶重新輸入。基本路徑: 1.用戶登錄火車訂票系統(tǒng)

2.購票用戶輸入自己的帳號和密碼 3.購票用戶提交信息

4.系統(tǒng)檢查用戶帳號和密碼是否匹配 5.系統(tǒng)記錄并顯示當(dāng)前用戶

擴(kuò)展點(diǎn):

4a:系統(tǒng)檢測到帳號有誤

4a1.用戶重新輸入 4a2.用戶離開系統(tǒng)

4b:購票用戶密碼錯誤

4b1:系統(tǒng)彈出密碼錯誤警告信息 4b2:購票用戶離開或重新輸入密碼

變異點(diǎn):無

用例編號:003 用例名:車票查詢

用例描述:在車票查詢頁面可以通過車次,始發(fā)地等信息查詢相關(guān)車次,獲得具體的車票信息

參與者:購票用戶

前置條件:電子商城正常運(yùn)行,用戶已登錄該系統(tǒng)

后置條件:用戶輸入的車次信息是在實(shí)際的火車運(yùn)行系統(tǒng)中存在的則顯示相應(yīng)的車票信息,否則,提示用戶輸入的信息有誤。基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶進(jìn)入車票查詢界面

3.購票用戶輸入要查詢的車票、車次或時(shí)間等信息 4.系統(tǒng)檢測輸入的信息是否正確 5.系統(tǒng)返回給用戶車票的具體信息

擴(kuò)展點(diǎn):

4a:系統(tǒng)檢測到用戶輸入的信息有誤

4a1.用戶重新輸入

4a2.用戶離開該功能界面

變異點(diǎn):無

用例編號:004 用例名:訂單查詢

用例描述:用戶在提交訂單后可以通過該功能查詢自己的訂單情況以及歷史訂單 參與者:購票用戶

前置條件:電子商城正常運(yùn)行,用戶已登錄該系統(tǒng)并在該系統(tǒng)已提交過訂單

后置條件:用戶提交信息后系統(tǒng)會查詢相關(guān)的數(shù)據(jù)庫信息,如果用戶提交過訂單,系統(tǒng)返回所有訂單(包括歷史訂單),否則提示用戶訂單列表為空 基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶進(jìn)入訂單查詢界面

3.購票用戶輸入要查詢的訂單的時(shí)間區(qū)間 4.系統(tǒng)調(diào)取用戶的訂單信息

5.系統(tǒng)返回給用戶想要的訂單信息(沒有訂單顯示空)

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:005 用例名:取消訂單

用例描述:該功能是訂單查詢的拓展功能,在訂單查詢之后可以選擇取消之前的訂單操作 參與者:購票用戶

前置條件:用戶在執(zhí)行完查詢訂單功能,并至少有一份未完成的訂單 后置條件:系統(tǒng)根據(jù)用戶的操作在系統(tǒng)數(shù)據(jù)庫中找到相應(yīng)數(shù)據(jù),如果符合條件則刪除該條訂單信息,否則,提示用戶沒有未完成的訂單 基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶進(jìn)入訂單查詢界面 3.用戶執(zhí)行取消訂單操作

4.系統(tǒng)檢測該操作是否符合取消訂單的條件 5.系統(tǒng)刪除用戶為完成的訂單

擴(kuò)展點(diǎn):

4a:用戶沒有未完成的訂單,用戶取消操作

變異點(diǎn):無

用例編號:006 用例名:車票預(yù)定

用例描述:該功能是車票查詢的拓展功能,在查詢完車票信息后可以繼續(xù)執(zhí)行該功能,完成車票的最后預(yù)定 參與者:購票用戶

前置條件:電子商城正常運(yùn)行,用戶已登錄該系統(tǒng)并查詢到自己需要的車票

后置條件:用戶提交信息后系統(tǒng)會查詢相關(guān)的數(shù)據(jù)庫信息,如果該車票有余票,則用戶預(yù)定成功,否則,提示用戶重新選擇車票或者放棄操作 基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶執(zhí)行車票查詢功能 3.用戶預(yù)定車票

4.系統(tǒng)檢測車票是否有余票 5.系統(tǒng)返回用戶預(yù)定成功

擴(kuò)展點(diǎn):

4a:車票已被全部出售

4a1:用戶重新選擇車票 4a2:用戶放棄該操作

變異點(diǎn):無

用例編號:007 用例名:信息查詢

用例描述:該功能可以讓用戶查詢自己的相關(guān)信息,包括帳號、密碼、姓名及郵箱等 參與者:購票用戶

前置條件:電子商城正常運(yùn)行,用戶登錄系統(tǒng)進(jìn)入自己的頁面

后置條件:用戶提交請求后系統(tǒng)從數(shù)據(jù)庫中調(diào)用與該用戶有關(guān)的所有信息 基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶提交信息查詢申請

3.系統(tǒng)調(diào)用數(shù)據(jù)庫中與該用戶有關(guān)的信息 4.系統(tǒng)把數(shù)據(jù)返回給用戶

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:008 用例名:修改信息

用例描述:該功能是信息查詢的拓展功能,主要指密碼、郵箱的修改 參與者:購票用戶

前置條件:電子商城正常運(yùn)行,用戶已登錄系統(tǒng)并執(zhí)行了查詢功能

后置條件:用戶提交修改信息功能后,系統(tǒng)對比修改信息需要的條件,如果符合則把用戶在系統(tǒng)數(shù)據(jù)庫中的信息修改,否則,提示信息修改失敗 基本路徑:

1.用戶執(zhí)行登錄帳號進(jìn)入自己的頁面 2.用戶執(zhí)行信息查詢功能 3.用戶填寫想要修改的信息 4.系統(tǒng)檢測相關(guān)條件 5.系統(tǒng)修改用戶的信息

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:009 用例名:添加用戶

用例描述:把新注冊的用戶添加到系統(tǒng)數(shù)據(jù)庫中 參與者:系統(tǒng)管理員

前置條件:有用戶條件注冊申請,管理員執(zhí)行添加操作

后置條件:如果用戶輸入的帳號在系統(tǒng)中未被注冊過,該用戶會注冊成功;否則,顯示帳號已注冊,提示用戶重新輸入。基本路徑:

1.管理員登錄系統(tǒng)

2.管理員執(zhí)行添加用戶操作 3.系統(tǒng)檢測用戶是否注冊

4.管理員將用戶信息添加到數(shù)據(jù)庫中

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:010 用例名:修改用戶

用例描述:該功能可以修改用戶的信息及用戶權(quán)限 參與者:系統(tǒng)管理員 前置條件:系統(tǒng)正常運(yùn)行

后置條件:管理員選擇修改用戶信息,系統(tǒng)修改用戶在數(shù)據(jù)庫中的信息 基本路徑:

1.管理員登錄系統(tǒng)

2.管理員執(zhí)行修改用戶操作 3.系統(tǒng)修改用戶信息

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:011 用例名:刪除用戶

用例描述:該功能可以把用戶從系統(tǒng)中徹底刪除 參與者:系統(tǒng)管理員 前置條件:系統(tǒng)正常運(yùn)行

后置條件:管理員選擇刪除用戶,將用戶從系統(tǒng)中徹底刪除 基本路徑:

1.管理員登錄系統(tǒng)

2.管理員執(zhí)行刪除用戶操作 3.系統(tǒng)將用戶徹底刪除

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:012 用例名:修改票務(wù)信息

用例描述:在車票的價(jià)格及火車的發(fā)車時(shí)間等實(shí)際信息更改后要在系統(tǒng)中做出相應(yīng)修改 參與者:系統(tǒng)管理員

前置條件:系統(tǒng)正常運(yùn)行,實(shí)際運(yùn)行的票務(wù)信息有變化

后置條件:管理員根據(jù)實(shí)際的修改對系統(tǒng)中的票務(wù)信息做出相應(yīng)修改 基本路徑:

1.管理員登錄系統(tǒng)

2.管理員執(zhí)行修改票務(wù)信息操作 3.系統(tǒng)重新存儲修改后的信息

擴(kuò)展點(diǎn):無 變異點(diǎn):無

用例編號:013 用例名:數(shù)據(jù)備份

用例描述:定期將重要數(shù)據(jù)進(jìn)行備份,防止數(shù)據(jù)丟失 參與者:系統(tǒng)管理員 前置條件:系統(tǒng)正常運(yùn)行

后置條件:管理員選擇數(shù)據(jù)備份,數(shù)據(jù)被備份存儲 基本路徑:

1.管理員登錄系統(tǒng)

2.管理員執(zhí)行數(shù)據(jù)備份操作 3.系統(tǒng)將重要數(shù)據(jù)進(jìn)行備份

擴(kuò)展點(diǎn):無 變異點(diǎn):無 2.2用例圖

3.類圖

3.1 實(shí)體類

3.2 邊界類

3.3控制類

4.對象圖

5.順序圖和協(xié)作圖

5.1用戶的順序圖和協(xié)作圖

(1)注冊帳號

:購票用戶:注冊界面:處理注冊:系統(tǒng)數(shù)據(jù)庫1: c_register2: submit_info3: check_account4: return_account5: register6: succeed1: c_register:購票用戶:注冊界面2: submit_info3: check_account5: register:處理注冊4: return_account6: succeed:系統(tǒng)數(shù)據(jù)庫

(2)登錄帳號

:購票用戶:登錄界面:處理登錄:系統(tǒng)數(shù)據(jù)庫1: c_login2: submit_info3: check_account4: account5: return_ok

1: c_login:購票用戶:登錄界面5: return_ok2: submit_info3: check_account:處理登錄4: account:系統(tǒng)數(shù)據(jù)庫

(3)車票查詢

:購票用戶:車票查詢界:查詢車票面1: c_query_ticket2: submit_ticket_info:車票數(shù)據(jù)3: request_info4: return_info1: c_query_ticket:購票用戶:車票查詢界面2: submit_ticket_info3: request_info:查詢車票4: return_info:車票數(shù)據(jù)

(4)車票預(yù)定

:購票用戶:車票查詢界:查詢車票面1: c_query_ticket2: submit_ticket_info:車票數(shù)據(jù)庫:預(yù)定車票:個人訂單3: request_info4: return_info5: c_reserve_ticket6: submit_order8: return_success7: create_order9: deliver_order

1: c_query_ticket5: c_reserve_ticket:購票用戶:車票查詢界面4: return_info2: submit_ticket_info:查詢車票8: return_success:車票數(shù)據(jù)庫3: request_info6: submit_order:個人訂單7: create_order9: deliver_order:預(yù)定車票

(5)訂單查詢 :購票用戶:訂單查詢界面:查詢訂單:個人信息:個人訂單1: query_order2: submit_info3: request_person_info4: return_info5: request_order6: return_order_info

1: query_order:購票用戶:訂單查詢界面2: submit_info:查詢訂單4: return_info6: return_order_info5: request_order3: request_person_info:個人訂單:個人信息

(6)取消訂單 :購票用戶:訂單查詢界面:查詢訂單:個人信息:個人訂單:取消訂單1: c_query_order2: submit_info3: request_person_info4: return_info5: request_order6: return_order_info7: c_cancel_order8: submit_cancel9: cancel_order10: return_success11: return_cancel_ok:購票用戶1: c_query_order7: c_cancel_order:訂單查詢界面6: return_order_info2: submit_info:查詢訂單8: submit_cancel5: request_order11: return_cancel_ok10: return_success3: request_person_info4: return_info:個人訂單:取消訂單9: cancel_order:個人信息

(7)信息查詢 :購票用戶:信息查詢界面:信息查詢:個人信息1: c_person_query2: submit_request3: query_info4: info5: return_person_info

1: c_person_query:購票用戶5: return_person_info:信息查詢界面2: submit_request3: query_info:信息查詢4: info:個人信息

(8)修改個人信息

:購票用戶:信息查詢界面:信息查詢:個人信息:修改信息1: c_person_query2: submit_request3: query_info4: info5: return_person_info6: c_edit_info7: request_edit8: edit_info9: true10: return_edit_ok1: c_person_query6: c_edit_info:購票用戶:信息查詢界面2: submit_request:信息查詢5: return_person_info10: return_edit_ok4: info3: query_info7: request_edit8: edit_info:修改信息9: true:個人信息

5.2 系統(tǒng)管理員的順序圖和協(xié)作圖

(1)添加用戶

:系統(tǒng)管理員:添加用戶界面:添加用戶:系統(tǒng)數(shù)據(jù)庫1: a_add_account2: add_request3: check_account4: true5: add_account6: ok7: return_add_ok1: a_add_account:添加用戶界面:系統(tǒng)管理員7: return_add_ok2: add_request3: check_account5: add_account:系統(tǒng)數(shù)據(jù)庫:添加用戶4: true6: ok

(2)刪除用戶

:系統(tǒng)管理員:刪除用戶界面:刪除用戶:用戶信息1: a_delete_account2: delete_request3: check_account4: true5: delete_account6: true7: return_delete_ok

:系統(tǒng)管理員1: a_delete_account7: return_delete_ok:刪除用戶界面:刪除用戶2: delete_request3: check_account5: delete_account4: true6: true:用戶信息

(3)修改用戶信息

:系統(tǒng)管理員:修改信息界面:修改用戶信息:用戶信息1: a_edit_account2: edit_request3: edit_info4: true5: return_edit_ok

1: a_edit_account:系統(tǒng)管理員:修改信息界面5: return_edit_ok2: edit_request3: edit_info:修改用戶信息4: true:用戶信息

(4)修改票務(wù)信息

:系統(tǒng)管理員:系統(tǒng)信息管理界面:票務(wù)信息修改:票務(wù)信息1: a_manage_info2: request_edit_ticket3: edit_info4: true5: get_info6: info7: return_new_info

:系統(tǒng)信息管理界面1: a_manage_info:系統(tǒng)管理員7: return_new_info2: request_edit_ticket3: edit_info5: get_info:票務(wù)信息修改:票務(wù)信息4: true6: info

(5)數(shù)據(jù)備份

:系統(tǒng)管理員:系統(tǒng)信息管理界面:數(shù)據(jù)備份:系統(tǒng)數(shù)據(jù):備份數(shù)據(jù)1: a_manage_info2: backup_request3: backup_data4: data5: restore_data6: success

1: a_manage_info:系統(tǒng)管理員:系統(tǒng)信息管理界面2: backup_request:數(shù)據(jù)備份4: data6: success3: backup_data5: restore_data:系統(tǒng)數(shù)據(jù):備份數(shù)據(jù)

6.狀態(tài)圖

6.1 車票狀態(tài)圖

添加車票車票可訂選定車票被選定提交訂單被預(yù)訂取消訂單完成支付已被取取票成功等待取票

6.2 用戶狀態(tài)圖

未注冊createAccountEvent已注冊關(guān)閉帳號帳號被注銷

7.組件圖

login.jspcustomer.javaregister.jspdata.java火車訂票系統(tǒng)java庫order_ticket.jsporder.javacancel_order.jspcancel.javaconsult_order.jspconsult.java

8.部署圖

路由器防火墻<>購票客戶瀏覽器web服務(wù)器<>數(shù)據(jù)服務(wù)器<>打印機(jī)系統(tǒng)管理員

9.總結(jié)

通過這次對火車訂票系統(tǒng)的建模分析,讓我對全程城一體化建模的理解更深了。在做系統(tǒng)分析的時(shí)候,遇到了很多問題。其中最大的問題就是,系統(tǒng)在實(shí)際做的時(shí)候跟想的時(shí)候差距是很大的。做系統(tǒng)的時(shí)候要注意到所有的細(xì)節(jié),要把每一步都想的非常清楚,只有這樣才能搭建一個合理的系統(tǒng)。

第二篇:火車訂票管理系統(tǒng)

學(xué)號11~15 選題三:火車票訂票管理系統(tǒng)

1.基本要求:為方便管理火車票購買信息,編寫一個火車票訂票管理系統(tǒng)軟件。系統(tǒng)記錄必須包括訂票人姓名、訂票人身份證號、始發(fā)站、終到站、票價(jià)、席別、訂票時(shí)間等。2.基本管理功能: [1] [2] 添加:增加一條訂票人的記錄到管理系統(tǒng)中。

查詢:根據(jù)訂票人身份證查找訂票人的相關(guān)信息并顯示,若找不到也要給出相應(yīng)提示。[3] [4] 修改:在管理系統(tǒng)中修改訂票人的訂票記錄。

保存:將所有訂票信息保存在一個文件中(數(shù)據(jù)庫文件或普通的文本文件)。[5] [6] [7] [8] 讀取:從文件中讀取已保存了數(shù)據(jù)。刪除:從管理系統(tǒng)中刪除一條記錄。恢復(fù):能恢復(fù)被刪除的記錄。

統(tǒng)計(jì):(A)統(tǒng)計(jì)每天訂票張數(shù)和總車票金額;(B)統(tǒng)計(jì)單價(jià)在100元以下、100~400元之間和400元以上的票數(shù)總張數(shù)及總金額;(C)以表格形式打印所有訂票信息。

源代碼:

#include #include #include #include using namespace std;

int d;//用于選擇(按1繼續(xù),按2退出,按他其他報(bào)錯待完善)int x=1;//用于脫出while循環(huán)

string sfz;//身份證號碼,用戶輸入可用到

class ticket {public: string ID;string name;string Sstation;string Tstation;float price;string seat;string time;ticket *next;ticket(string I,string n,string S, string T,float p, string s,string t){ID=I;name=n;Sstation=S;Tstation=T;price=p;seat=s;time=t;} void display();};

void ticket::display(){cout<

cout<<“|”<void menu(){cout<

************歡迎使用 ************”<

**請輸入選項(xiàng)前的編號**”<

**************************************************************”<

*

1.添加車票信息

*”<

*

2.查詢車票信息

*”<

*

3.修改車票信息

*”<

*

4.刪除車票信息

*”<

*

5.恢復(fù)車票信息

*”<

*

6.顯示車票信息

*”<

*

7.統(tǒng)計(jì)車票信息

*”<

*

8.保存車票信息

*”<

*

9.讀取車票信息

*”<

*

0.離開

*”<

**************************************************************”<

ticket *head=NULL,*del=NULL,*p0,*p1,*p2,*p3,*p4;//head數(shù)據(jù)鏈表頭指針,p0,p1,p2添加函數(shù)專用,避免發(fā)生錯誤

int check(string b)//身份證號碼作為功能基本辨別數(shù)據(jù),應(yīng)該有一個函數(shù)專門檢查其是否重復(fù),0 表示重復(fù),1 表示不重復(fù) {ticket *ch;ch=head;int che=1;while(ch!=NULL)

{if(ch->ID==b){che=0;ch=NULL;}

else {ch=ch->next;}

} return che;}

int check1(string b)// sbl {ticket *ch;ch=del;int che=1;while(ch!=NULL)

{if(ch->ID==b){che=0;ch=NULL;}

else {ch=ch->next;}

} return che;}

int add()//將訂票數(shù)據(jù)保存在一個基礎(chǔ)鏈表中 {system(“cls”);float price;string name,ID,Sstation,Tstation,seat,time;

if(head==NULL)//以下為鏈表為空的情況 { cout<<“=============開始輸入訂票信息=============”<

cout<<“請輸入訂票人身份證號碼:”;cin>>ID;cout<<“請輸入訂票人姓名:”;cin>>name;cout<<“請輸入始發(fā)站:”;cin>>Sstation;

cout<<“請輸入終點(diǎn)站:”;cin>>Tstation;

cout<<“請輸入票價(jià):”;cin>>price;cout<<“請輸入席別:”;cin>>seat;cout<<“請輸入訂票時(shí)間(年月日以“-”隔開):”;cin>>time;

head=p1=p2=new ticket(ID,name,Sstation,Tstation,price,seat,time);x=1;while(x){system(“cls”);

cout<<“按1繼續(xù)輸入,按2退出-》”;

cin>>d;

if(d==1)

{system(“cls”);

p1->next=NULL;

cout<<“=============開始輸入訂票信息=============”<

cout<<“請輸入訂票人身份證號碼:”;

cin>>ID;

if(check(ID)==0){cout<<“身份證號碼重復(fù)!”<

system(“pause”);

return 0;}

cout<<“請輸入訂票人姓名:”;

cin>>name;

cout<<“請輸入始發(fā)站:”;

cin>>Sstation;

cout<<“請輸入終點(diǎn)站:”;

cin>>Tstation;

cout<<“請輸入票價(jià):”;

cin>>price;

cout<<“請輸入席別:”;

cin>>seat;

cout<<“請輸入訂票時(shí)間(年月日以“-”隔開):”;

cin>>time;

p1=new ticket(ID,name,Sstation,Tstation,price,seat,time);

p2->next=p1;

p2=p1;

}

else if(d==2)

{p1->next=NULL;

x=0;

}

else {cout<<“非法輸入!”<

} //以上為鏈表為空的情況

else //以下為鏈表已有數(shù)據(jù),往末尾添加

{p3=head;

while(p3->next!=NULL)

{p3=p3->next;}

x=1;

while(x)

{system(“cls”);

cout<<“=============開始輸入訂票信息=============”<

cout<<“請輸入訂票人身份證號碼:”;

cin>>ID;

if(check(ID)==0){cout<<“身份證號碼重復(fù)!”<

system(“pause”);

return 0;}

cout<<“請輸入訂票人姓名:”;

cin>>name;

cout<<“請輸入始發(fā)站:”;

cin>>Sstation;

cout<<“請輸入終點(diǎn)站:”;

cin>>Tstation;

cout<<“請輸入票價(jià):”;

cin>>price;

cout<<“請輸入席別:”;

cin>>seat;

cout<<“請輸入訂票時(shí)間(年月日以“-”隔開):”;

cin>>time;

p0=new ticket(ID,name,Sstation,Tstation,price,seat,time);

p3->next=p0;

p3=p0;

system(“cls”);

cout<<“按1繼續(xù)輸入,按2退出-》”;

cin>>d;

if(d==1){x=1;p3->next=NULL;}

else if(d==2){p3->next=NULL;x=0;}

else

{cout<<“非法輸入!”<

} } //以上為鏈表已有數(shù)據(jù),往末尾添加

return 1;}

ticket *search1(string a)//查詢函數(shù)1,用于輸入身份證號碼返回一個指針,可在其他部分被使用

{ticket *cha1;cha1=head;x=1;while(x)

{if(cha1==NULL){x=0;}

else if(cha1->ID==a){x=0;}

else {cha1=cha1->next;}

} return cha1;}

ticket *search_1(string a)//改查1后面都得改,嗯,就這樣了(~ ̄▽ ̄)~ {ticket *cha1;cha1=del;x=1;while(x)

{if(cha1==NULL){x=0;}

else if(cha1->ID==a){x=0;}

else {cha1=cha1->next;}

} return cha1;}

ticket *search2(string b)//查詢函數(shù)2,返回所要查詢結(jié)點(diǎn)的前一個結(jié)點(diǎn)的指針,在刪除部分使用

{ticket *cha2,*cha3;cha2=cha3=head;x=1;while(x)

{if(cha2->next==NULL){x=0;}

else if(cha2->ID==b){x=0;}

else {cha3=cha2;

cha2=cha2->next;}

} return cha3;}

ticket *search_2(string b)//-_-{ticket *cha2,*cha3;cha2=cha3=del;x=1;while(x)

{if(cha2->next==NULL){x=0;}

else if(cha2->ID==b){x=0;}

else {cha3=cha2;

cha2=cha2->next;}

} return cha3;}

void search()//用于用戶查詢功能(目前只能查詢一次,然后退出,待完善){system(“cls”);cout<<“請輸入身份證號碼:”;cin>>sfz;p3=search1(sfz);if(p3==NULL){cout<<“無相關(guān)信息!”<

cout<<“|”<

cout<<“----------”<

p3->display();system(“pause”);} }

void display1()// {system(“cls”);ticket *dis;cout<

{dis->display();

dis=dis->next;

} while(dis!=NULL);}

void modify()//修改函數(shù),用于修改數(shù)據(jù)(目前只可以修改單個訂票信息,待完善){system(“cls”);display1();cout<<“請輸入要修改信息的身份證號碼:”;cin>>sfz;p3=search1(sfz);if(p3==NULL){cout<<“無相關(guān)信息!”<

while(x)

{system(“cls”);

cout<<“1.身份證號碼 2.姓名 3.始發(fā)站 4.終點(diǎn)站 5.票價(jià) 6.席別 7.時(shí)間”<

cout<<“請輸入要修改的選項(xiàng)前的編號:”;

cin>>d;

if(d==1){hui2: cout<<“請輸入身份證號碼:”;

cin>>sfz;

if(check(sfz)==0){cout<<“身份證號碼重復(fù)!”<

goto hui2;}

p3->ID=sfz;

}

else if(d==2){cout<<“請輸入姓名:”;cin>>p3->name;}

else if(d==3){cout<<“請輸入始發(fā)站:”;cin>>p3->Sstation;}

else if(d==4){cout<<“請輸入終點(diǎn)站:”;cin>>p3->Tstation;}

else if(d==5){cout<<“請輸入票價(jià):”;cin>>p3->price;}

else if(d==6){cout<<“請輸入席別:”;cin>>p3->seat;}

else if(d==7){cout<<“請輸入時(shí)間:”;cin>>p3->time;}

else {cout<<“非法輸入!”<

hui1: cout<<“按1繼續(xù)輸入,按2退出-》”;

int d1;

cin>>d1;

if(d1==1){x=1;}

else if(d1==2){x=0;}

else {cout<<“非法輸入!”<

}

} }

void Darea(ticket *c)//將刪除信息儲存在另一鏈表中 {if(del==NULL){del=c;del->next=NULL;} else {ticket *Dar;

Dar=del;

while(Dar->next!=NULL)

{Dar=Dar->next;}

Dar->next=c;

Dar=c;

Dar->next=NULL;

} }

void Delete()//刪除函數(shù)將要刪除的訂票信息移出鏈表,并將所有刪除信息結(jié)成另一鏈表,供恢復(fù)使用 {system(“cls”);display1();cout<<“請輸入要刪除訂票信息的身份證號碼:”;cin>>sfz;p3=search1(sfz);p4=search2(sfz);if(p3==NULL){cout<<“無相關(guān)信息!”<next;Darea(p3);cout<<“刪除成功!”<next==NULL){p4->next=NULL;Darea(p3);cout<<“刪除成功!”<next=p3->next;Darea(p3);cout<<“刪除成功!”<next;} else if(p3->next==NULL){p4->next=NULL;} else {p4->next=p3->next;} }

void recover()//恢復(fù)函數(shù),用于將已經(jīng)刪除的訂票信息恢復(fù) {system(“cls”);ticket *r1,*r2,*r3;if(del==NULL){cout<<“無可恢復(fù)訂票信息!”<

cout<<“|”<

cout<<“----------”<

r1=del;

if(del!=0)

do

{r1->display();

r1=r1->next;

}

while(r1!=NULL);hui3: cout<<“請輸入要恢復(fù)的訂票信息的身份證號碼:”;

cin>>sfz;

if(check1(sfz)==1){cout<<“非法輸入!”<

r2=head;

while(r2->next!=NULL){r2=r2->next;}

r3=search_1(sfz);

r2->next=r3;

r3->next=NULL;

Rdel(sfz);

cout<<“成功恢復(fù)!”<

system(“pause”);

} }

void display()//顯示基礎(chǔ)鏈表中的所有訂票信息 {system(“cls”);ticket *dis;cout<

{dis->display();

dis=dis->next;

} while(dis!=NULL);system(“pause”);}

void count()//統(tǒng)計(jì)部分 {system(“cls”);if(head==NULL){cout<<“無可統(tǒng)計(jì)信息!”<

n=0,n1=0,n2=0,n3=0;

float i,m=0,m1=0,m2=0,m3=0;

p3=head;

while(p3!=NULL)

{i=p3->price;

n=n+1;

m=m+i;

if(i<100){n1=n1+1;m1=m1+i;}

if(i>=100&&i<=400){n2=n2+1;m2=m2+i;}

if(i>400){n3=n3+1;m3=m3+i;}

p3=p3->next;

}

cout<

cout<<“|”<

cout<<“-------------------”<

cout<<“|”<

cout<<“|”<

cout<<“|”<

cout<<“|”<

system(“pause”);

} }

void save()//保存函數(shù) {system(“cls”);string filename,filename1;ofstream file;cout<<“請輸入文件名:”;cin>>filename1;filename1=filename1+“.txt”;filename=“C:Program Files(x86)Microsoft Visual StudioMyProjects火車票訂票管理系統(tǒng)savedata”+filename1;//此處路徑根據(jù)需要自行更改

/*file.open(filename.c_str(),ios::in);//功能失敗部分待完善

if(!file){d=1;} else

{d=2;} file.close();if(d==1){file.open(filename.c_str(),ios::out);

p1=head;

x=1;

while(x)

{if(p1!=NULL)

{file<

ID<

name<

Sstation<

Tstation<

price<

seat<

time<

p1=p1->next;}

else {x=0;}

}

file.close();

cout<<“保存成功”<

if(d==2){ */ int i;// cout<<“文件已存在!”<

cin>>i;

if(i==1)

{file.open(filename.c_str(),ios::out);

p3=head;

x=1;

while(x)

{if(p3!=NULL)

{file<

ID<name<Sstation<Tstation<price<seat<time<

p3=p3->next;}

else {x=0;}

}

file.close();

cout<<“保存成功”<

} else if(i==2)

{file.open(filename.c_str(),ios::app);

p3=head;

x=1;

while(x)

{if(p3!=NULL)

{file<

ID<name<Sstation<Tstation<price<seat<time<

p3=p3->next;}

else {x=0;}

}

file.close();

cout<<“保存成功”<

} else {cout<<“非法輸入!”;goto hui;} //} }

int load()//讀取函數(shù) {system(“cls”);int i=0,ii=0,j=0;ifstream infile;string filename,filename1;cout<<“請輸入文件名:”;cin>>filename1;filename1=filename1+“.txt”;filename=“C:Program Files(x86)Microsoft Visual StudioMyProjects火車票訂票管理系統(tǒng)savedata”+filename1;//此處路徑根據(jù)需要自行更改

infile.open(filename.c_str(),ios::in);

if(!infile){cerr<<“讀取失敗!”<

system(“pause”);

return-1;}

string a[1000];//能力有限,不會動態(tài)大小,只能這樣了(+﹏+)~ while(!infile.eof()){getline(infile,a[i],'n');

i++;} ticket *L1,*L2;float f;for(ii=0;ii

{f=atof(a[ii+4].c_str());

head=new ticket(a[ii],a[ii+1],a[ii+2],a[ii+3],f,a[ii+5],a[ii+6]);

head->next=NULL;

}

else

{L1=head;

while(L1->next!=NULL)

{L1=L1->next;}

f=atof(a[ii+4].c_str());

L2=new ticket(a[ii],a[ii+1],a[ii+2],a[ii+3],f,a[ii+5],a[ii+6]);

L1->next=L2;

L1=L2;

L1->next=NULL;

} }

infile.close();cout<<“讀取成功”<

void select()//選擇功能分支 {system(“cls”);menu();cin>>d;

if(d==1){add();select();}

if(d==2){search();select();}

if(d==3){modify();select();}

if(d==4){Delete();select();}

if(d==5){recover();select();}

if(d==6){display();select();}

if(d==7){count();select();}

if(d==8){save();select();}

if(d==9){load();select();} else if(d==0)

{ticket *ex1,*ex2,*ex3,*ex4;

ex1=head;

while(ex1!=NULL)

{ex2=ex1;

ex1=ex1->next;

delete ex2;

}

ex3=del;

while(ex3!=NULL)

{ex4=ex3;

ex3=ex3->next;

delete ex4;

}

cout<<“離開!”<

exit(0);} else {cout<<“錯誤!”<

int main(){head=NULL;select();return 0;}

//較多bug,比如,如果先恢復(fù)第一個會導(dǎo)致后面的數(shù)據(jù)全部丟失,時(shí)間能力有限,實(shí)在抱歉->_<-

第三篇:火車訂票系統(tǒng)c++程序

/* 頭文件 */ #include //標(biāo)準(zhǔn)輸入、輸出頭文件

#include //包含字符串函數(shù)處理頭文件

#include //包含動態(tài)存儲與釋放函數(shù)頭文件 /* 宏定義 */ #define GESHI “ 車次 站數(shù) 起始站 終點(diǎn)站 開車時(shí)間 到達(dá)時(shí)間 票數(shù)n” //輸出表頭 #define PRINT “ %5s%10s%10s%10s%13s%13s%10dn”,s[i].code,s[i].data,s[i].lp,s[i].ap,s[i].lt,s[i].at,s[i].count //輸出記錄格式 #define N 1000 //最大列車組數(shù) /* 結(jié)構(gòu)定義 */ struct train //定義結(jié)構(gòu)體數(shù)組 { char code[10];//車次 char data[10];//站數(shù) char lp[20];//起始站 char ap[20];//終點(diǎn)站

char lt[10];//開車時(shí)間 char at[10];//到達(dá)時(shí)間 int count;//票數(shù) }s[N];/* 全局變量 */ int i;//輸入計(jì)數(shù)器 int m=0;//合計(jì)計(jì)數(shù)器 char l[20];//糾錯空間 /* 函數(shù)聲明 */ void INPUT();//輸入車次信息 void PRINTF();//輸出車次信息 void save();//保存車次信息 void read();//讀取車次信息 void search();//查找車次信息 void dingpiao();//訂票信息 void tuipiao();//退票信息 void WRONG();//糾錯模塊

///////////////////////////////////////////////////////////////////////////////////////主函數(shù) void main(){

int j;do { system(“cls”);//清屏語句 printf(“ *************************************************************n”);printf(“ 歡迎進(jìn)入火車票務(wù)管理系統(tǒng) n”);printf(“ *************************************************************”);printf(“ n

請輸入選項(xiàng) nn”);printf(“ 1.添加列車信息 nn” “

2.查找 nn” “

3.訂票 nn” “

4.退票 nn” “

5.退出 nn”);printf(“ *************************************************************nn”);printf(“請選擇: ”);scanf(“%d”,&j);gets(l);

switch(j){ case 1: INPUT();//調(diào)用輸入模塊 break;case 2:search();//調(diào)用查找模塊 break;case 3:dingpiao();//調(diào)用訂票模塊 break;case 4:tuipiao();//調(diào)用退票模塊 break;case 5:;break;default:WRONG();break;} }while(j!=5);//判斷結(jié)束

printf(“n

王志強(qiáng)

1241班 201210913124 n ”);printf(“n--------”);

printf(“n 正在退出,請按任意鍵退出”);

printf(“n--------n ”);}//主函數(shù)結(jié)束

//////////////////////////////////////////////////////////////////////////////////////////輸入模塊 void INPUT(){

int y;

system(“cls”);printf(“n ====================歡迎進(jìn)入 錄入火車時(shí)刻信息 界面====================nn”);for(i=0;i

printf(“請輸入車次號: ”);scanf(“%s”,&s[i].code);//讀取車次號 printf(“請輸入站數(shù): ”);scanf(“%s”,&s[i].data);//讀取站數(shù) printf(“請輸入起始站: ”);scanf(“%s”,s[i].lp);//讀取起始站 printf(“請輸入終點(diǎn)站: ”);scanf(“%s”,s[i].ap);//讀取終點(diǎn)站 printf(“請輸入開車時(shí)間: ”);scanf(“%s”,s[i].lt);//讀取開車時(shí)間 printf(“請輸入到達(dá)時(shí)間: ”);scanf(“%s”,s[i].at);//讀取到達(dá)時(shí)間 printf(“請輸入車票數(shù): ”);scanf(“%d”,&s[i].count);//讀取票數(shù) m++;

printf(“第%d個信息已經(jīng)輸完.按任意鍵繼續(xù),按 0 結(jié)束: ”,m);scanf(“%d”,&y);gets(l);if(y==0){ save();//將結(jié)構(gòu)體信息存盤 PRINTF();//輸出輸入的列車信息

printf(“n 按任意鍵返回上級菜單: ”);gets(l);break;} }

} ////////////////////////////////////////////////////////////////////////保存模塊程序 void save(){ FILE *fp,*fp1;//定義文件指針

if((fp=fopen(“chen.dat”,“wb”))==NULL)//打開文件并判斷是否出錯 { printf(“創(chuàng)建文件失敗!nn”);//打印出錯提示 getchar();return;} if((fp1=fopen(“hao.dat”,“wb”))==NULL)//打開文件并判斷是否出錯 { printf(“創(chuàng)建文件失敗!nn”);//打印出錯提示 getchar();return;}

for(i=0;i

printf(“向文件輸入數(shù)據(jù)失敗!nn”);fprintf(fp1,“%d”,m);fclose(fp);//關(guān)閉文件 fclose(fp1);//關(guān)閉文件 }

///////////////////////////////////////////////////////////////////////文件讀取模塊 void read(){ FILE *fp,*fp1;//定義文件指針

if((fp=fopen(“chen.dat”,“rb”))==NULL)//打開文件,并判斷是否出錯 { printf(“出錯,請檢查文件是否存在,按任意鍵返回住菜單”);//打印出錯提示

getchar();} if((fp1=fopen(“hao.dat”,“rb”))==NULL)//打開文件并判斷是否出錯 { printf(“創(chuàng)建文件失敗!nn”);//打印出錯提示 getchar();return;} fscanf(fp1,“%d”,&m);fclose(fp1);//關(guān)閉文件 for(i=0;i

//////////////////////////////////////////////////////////////////////////////查詢模塊 void search(){ char name1[20];char name2[20];char ii[10];int nk;char no[10];do { system(“cls”);//清屏語句

printf(“nn ====================歡迎進(jìn)入 查詢火車時(shí)刻信息 界面====================n”);

printf(“n

++++++++++++++++++請選擇查找方式++++++++++++++++++nn”);

printf(“

----1.顯示所有列車信息

2.按車次查詢 3.按始發(fā)站查詢----n”);

printf(“

-----4.按終點(diǎn)站查詢

5.返回主菜單----n”);

printf(“n 請選擇: ”);scanf(“%d”,&nk);//讀取查找方式 gets(l);if(nk==5)break;

switch(nk){ case 1:PRINTF();//調(diào)用打印模塊 break;case 2: printf(“請輸入車次號:n”);scanf(“%s”,&no);//車次號 break;case 3: printf(“請輸入始發(fā)站名稱:n”);scanf(“%s”,name1);//讀取始發(fā)站 break;case 4: printf(“請輸入終點(diǎn)站名稱:n”);scanf(“%s”,name2);//終點(diǎn)站 break;default:

WRONG();

break;} read();//調(diào)用讀取函數(shù) for(i=0;i>是否繼續(xù)查找?(y/n)<--------nntt”);scanf(“%s”,ii);}while(strcmp(ii,“y”)==0);//判斷結(jié)束 } ///////////////////////////////////////////////////////////////////////////////////訂票模塊 void dingpiao(){ int n;char a[10];do { system(“cls”);

search();//調(diào)用查詢模塊

printf(“請輸入您要訂的車票數(shù)以回車鍵結(jié)束:”);scanf(“%d”,&n);//讀取所訂機(jī)票數(shù) if(n<0){ system(“cls”);WRONG();//scanf(“%s”,l);//gets(l);

break;} if(s[i].count!=0&&s[i].count>=n)//判斷是否出錯 { s[i].count=s[i].count-n;//調(diào)用保存函數(shù)

system(“cls”);printf(“訂票成功!nn”);printf(“ntt按任意鍵返回主菜單: ”);scanf(“%s”,l);

break;} if(s[i].count

break;} printf(“是否繼續(xù)?(y/n):n”);//判斷是否繼續(xù)訂票 scanf(“%s”,a);}while(!strcmp(a,“y”));//判斷結(jié)束

} ///////////////////////////////////////////////////////////////////////////////退票模塊 void tuipiao(){ int n;char a;do { search();//調(diào)用查詢模塊

printf(“請輸入您要退的機(jī)票數(shù)目:n”);scanf(“%d”,&n);//輸入所退票數(shù)

gets(l);if(n<0)//判斷票數(shù)是否有效

{

WRONG();

break;} s[i].count=s[i].count+n;do

{

system(“cls”);//借鑒而來的清屏語句,好用!

printf(“nn-->退票成功<--”);printf(“nn-->繼續(xù) y,返回主菜單 n <--”);

a=getchar();

gets(l);

if(a!='y'&&a!='n')

WRONG();

}while(a!='y'&&a!='n');}while(a!='n');//判斷并跳出循環(huán) } ///////////////////////////////////////////////////////////////////////////////////////糾錯模塊 void WRONG(){ system(“cls”);//借鑒而來的清屏語句,好用!

printf(“nn--->!!輸入錯誤,請按任意鍵返回!!<---”);gets(l);}

第四篇:火車訂票管理系統(tǒng)主程序流程

程序簡介

此程序是采用多文件模塊化形式編寫;其中自定義頭文件中包括了程序中所有調(diào)用的函數(shù)的聲明,以及需要的所有系統(tǒng)頭文件。

#include #include #include #include #include #include extern void searchtrain(link l);extern void Modify(link l);extern void showtrain(link l);extern void SaveTrainInfo(link l);extern void printdata(Node *q);extern void printhead();等

編寫時(shí)的分塊包括訂票塊、查詢塊、輸出塊,及已訂票修改部分等。

訂票塊則包含了定票流程的所有代碼。查詢塊中是通過車次號碼或是到達(dá)城市來查詢的。輸出部分包括了主界面的輸出,已定車票信息的輸出,所查車次信息輸出的頭部分。訂票修改即是改定過程的編程。

即此程序包括了查詢、訂票、改定的流程。

編程過程

在編寫該程序時(shí),遇到了信息的保存問題。訂票時(shí)與改定時(shí)的錄入信息的保存不知如何處理;之后將保存的部分分為鏈表暫存和文件的保存,在錄入信息時(shí)是暫存在鏈表中的,當(dāng)離開此系統(tǒng)是會提示是否保存信息,若是則保存到文件中。此舉方便了票的改定,將數(shù)據(jù)分割開了,也精簡了程序,更便于閱讀。

編程模塊劃分后,編寫程序之后的編譯時(shí),總是連分文件編譯時(shí)都無法通過。但是寫入的代碼經(jīng)過檢查又沒有問題,一直困擾著我。直到想起老師教的課本以外的知識,并以一種玩玩試一試的心態(tài)用條件編譯得以解決此問題。

同時(shí)在編程時(shí)多次用到“清屏”,保證了輸出界面的簡潔。

在分出模塊后,未完成所有部分的編程時(shí)的試運(yùn)行時(shí)出現(xiàn)剛一進(jìn)入子程序時(shí)便會回到主界面,后發(fā)現(xiàn)時(shí)由于只有輸出部分沒有輸入部分,每當(dāng)運(yùn)行完子程序后回到主程序時(shí)都會被“清屏”,結(jié)果造成編譯時(shí)正常,到運(yùn)行時(shí)卻漏洞百出。

在編程時(shí),由于對文件的處理不熟悉,以及計(jì)算機(jī)的設(shè)置問題沒考慮,使用了‘w+’的調(diào)用方式,使得在保存數(shù)據(jù)到文件時(shí)出現(xiàn)無法寫入文件的現(xiàn)象。在百度,問同學(xué)以及問老師后才用‘wb+’和別的方式調(diào)用,并寫入成功。

這個程序時(shí)我學(xué)習(xí)計(jì)算機(jī)c以來編寫的最大型涵蓋面最廣的一個程序,沒有之一。但同時(shí)我也知道這在c語言編程中也只是很小的一個小程序而已,我在這編程中發(fā)現(xiàn):我要學(xué)的還有很多,大型程序也不是一個人能寫出來的,會一些編程技巧是很有必要的,與人合作是

– 1 – 必須的,當(dāng)然了,我不是在寫詩,而是真的這么覺得。一個人會的有限,專精方向也不同,若能好好的合作肯定可以超過一個人單干。

部分源代碼

訂票程序

#ifndef TRAINHEAD_H #define TRAINHEAD_H #include“trainhead.h” #endif/*條件編譯,作用是防止頭文件被重復(fù)引用*/ int saveflag = 0;void Bookticket(link l,booklink k){ Node *p[10],*q;char c[2],tnum[10],str[10],str1[10];Book *r,*s;int i = 0,t = 0,flag = 0,dnum;r = k;while(r->next!=NULL)

r = r->next;printf(“Input the city you want to go:”);scanf(“%s”,&str);q = l->next;while(q!=NULL)

{

if(strcmp(q->data.reachcity,str)==0)

{

p[i] = q;

i++;

}

q = q->next;

}

printf(“nthe number of record have %dn”,i);

printhead();

for(t=0;t

printdata(p[t]);

if(i==0)

printf(“nSorry!Can't find the train for you!n”);

else

{

printf(“ndo you want to book it?n”);– 2 –

scanf(“%s”,c);

if(strcmp(c,“Y”)==0||strcmp(c,“y”)==0)/*判斷是否訂票*/

{

s =(Book*)malloc(sizeof(Book));

printf(“nInput your name: ”);

scanf(“%s”,&s->data.name);

printf(“nInput your ID: ”);

scanf(“%s”,&str1);

相應(yīng)減少*/

strcpy(s->data.num,str1);printf(“nplease input the number of the train:”);scanf(“%s”,tnum);for(t=0;tdata.num,tnum)==0){ if(p[t]->data.ticketnum < 1)/*判斷剩余的供訂票的票數(shù)是否為0*/ {

printf(“nsorry,no ticket!”);

Sleep(2);

return;} printf(“nremain %d ticketsn”,p[t]->data.ticketnum);flag = 1;break;} if(flag==0){ printf(“ninput error”);Sleep(2);return;} printf(“nInput your bookNum: ”);scanf(“%d”,&dnum);p[t]->data.ticketnum=p[t]->data.ticketnum-dnum;/*定票成功則可供訂的票數(shù)s->data.bookNum = dnum;s->next = NULL;r->next = s;r = s;printf(“nLucky!you have booked a ticket!”);getch();

– 3 –

} } } saveflag = 1;使用說明

運(yùn)行程序時(shí),首先進(jìn)入到菜單部分,菜單部分提供了菜單顯示和輸入功能部分。其運(yùn)行效果如圖19.1所示。在主界面上輸入數(shù)字0——6,實(shí)現(xiàn)相應(yīng)的功能。

圖19.1 火車訂票系統(tǒng)主界面

主界面輸入“1”,進(jìn)入添加火車信息界面,如圖19.2所示。根據(jù)屏幕上給出的提示輸入火車的車次,起點(diǎn),終點(diǎn),出發(fā)時(shí)間,到達(dá)時(shí)間,票價(jià)和可以訂購的票數(shù)。

– 4 –

圖19.2 輸入效果圖

主界面輸入“2”,可以查詢火車信息,可以選擇查詢的方法有兩種,一種是按照車次查詢,一種是按照你想要到達(dá)的地方查詢,運(yùn)行效果如圖19.3所示。

– 5 –

圖19.3 查詢效果圖

當(dāng)在主界面輸入“3”時(shí),進(jìn)入訂票界面,按照提示輸入你想要到達(dá)的城市,會自動顯示出你終點(diǎn)站為你輸入城市的信息,根據(jù)提示輸入你是否決定訂票以及你的個人信息,運(yùn)行效果如圖19.4所示。

圖19.4 訂票效果圖

當(dāng)在主界面輸入“4”時(shí),進(jìn)入修改界面,根據(jù)提示輸入你要修改的內(nèi)容,修改模塊的運(yùn)行效果如圖19.5所示。

– 6 –

圖19.5 修改效果圖

當(dāng)在主界面輸入“5”時(shí),可以顯示出所有的火車信息,顯示模塊效果如圖19.6所示。

– 7 –

圖19.6 顯示效果圖

當(dāng)在主界面輸入“6”時(shí),進(jìn)入到保存模塊,將錄入的火車信息進(jìn)行保存,并且將訂票人的信息也進(jìn)行保存,存儲在指定的磁盤文件中。運(yùn)行效果如圖19.7所示。

圖19.7 保存效果圖

– 8 –

第五篇:C語言編程---火車訂票系統(tǒng)源代碼

火車訂票系統(tǒng)源碼

#include #include #include #include

intshoudsave=0;int count1=0,count2=0,mark=0,mark1=0;/*定義存儲火車信息的結(jié)構(gòu)體*/ struct train {

char num[10];/*列車號*/

char city[10];/*目的城市*/

char takeoffTime[10];/*發(fā)車時(shí)間*/

char receiveTime[10];/*到達(dá)時(shí)間*/ int price;/*票價(jià)*/ intbookNum;/*票數(shù)*/ };/*訂票人的信息*/ struct man { charnum[10];/*ID*/

char name[10];/*姓名*/ intbookNum;/*需求的票數(shù)*/ };/*定義火車信息鏈表的結(jié)點(diǎn)結(jié)構(gòu)*/ typedefstruct node { struct train data;struct node * next;}Node,*Link;/*定義訂票人鏈表的結(jié)點(diǎn)結(jié)構(gòu)*/ typedefstruct people { struct man data;struct people*next;}bookMan,*bookManLink;/* 初始界面*/ voidprintInterface(){ puts(“********************************************************”);puts(“*

Welcome to use the system of booking tickets

*”);puts(“********************************************************”);puts(“*

You can choose the operation:

*”);puts(“*

1:Insert a train information

*”);puts(“*

2:Inquire a train information

*”);puts(“*

3:Book a train ticket

*”);puts(“*

4:Update the train information

*”);puts(“*

5:Advice to you about the train

*”);puts(“*

6:save information to file

*”);puts(“*

7:quit the system

*”);puts(“********************************************************”);} /*添加一個火車信息*/ voidInsertTraininfo(Link linkhead){ struct node *p,*r,*s;charnum[10];

r = linkhead;

s = linkhead->next;while(r->next!=NULL)

r=r->next;while(1)

{ printf(“please input the number of the train(0-return)”);scanf(“%s”,num);if(strcmp(num,“0”)==0)break;

/*判斷是否已經(jīng)存在*/ while(s)

{ if(strcmp(s->data.num,num)==0)

{ printf(“the train '%s'has been born!n”,num);return;

}

s = s->next;

}

p =(struct node*)malloc(sizeof(struct node));strcpy(p->data.num,num);printf(“Input the city where the train will reach:”);scanf(“%s”,p->data.city);printf(“Input the time which the train take off:”);scanf(“%s”,p->data.takeoffTime);printf(“Input the time which the train receive:”);scanf(“%s”,&p->data.receiveTime);printf(“Input the price of ticket:”);scanf(“%d”,&p->data.price);printf(“Input the number of booked tickets:”);scanf(“%d”,&p->data.bookNum);p->next=NULL;r->next=p;

r=p;shoudsave = 1;

} } /*打印火車票信息*/ voidprintTrainInfo(struct node*p){ puts(“nThe following is the record you want:”);printf(“>>number of train: %sn”,p->data.num);printf(“>>city the train will reach: %sn”,p->data.city);printf(“>>the time the train take off: %snthe time the train reach: %sn”,p->data.takeoffTime,p->data.receiveTime);printf(“>>the price of the ticket: %dn”,p->data.price);printf(“>>the number of booked tickets: %dn”,p->data.bookNum);}

struct node * Locate1(Link l,charfindmess[],char numorcity[]){

Node*r;if(strcmp(numorcity,“num”)==0)

{

r=l->next;while(r)

{ if(strcmp(r->data.num,findmess)==0)return r;

r=r->next;

}

} else if(strcmp(numorcity,“city”)==0)

{

r=l->next;while(r)

{ if(strcmp(r->data.city,findmess)==0)return r;

r=r->next;

}

} return 0;}

/*查詢火車信息*/ voidQueryTrain(Link l){

Node *p;intsel;char str1[5],str2[10];if(!l->next)

{ printf(“There is not any record!”);return;

} printf(“Choose the way:n>>1:according to the number of train;n>>2:according to the city:n”);scanf(“%d”,&sel);if(sel==1)

{ printf(“Input the the number of train:”);scanf(“%s”,str1);

p=Locate1(l,str1,“num”);if(p)

{ printTrainInfo(p);

} else

{

mark1=1;printf(“nthe file can't be found!”);

}

} else if(sel==2)

{ printf(“Input the city:”);scanf(“%s”,str2);

p=Locate1(l,str2,“city”);if(p)

{ printTrainInfo(p);

} else

{

mark1=1;printf(“nthe file can't be found!”);

}

} }

/*訂票子模塊*/ voidBookTicket(Link l,bookManLink k){

Node*r[10],*p;charch,dem;bookMan*v,*h;int i=0,t=0;charstr[10],str1[10],str2[10];

v=k;while(v->next!=NULL)

v=v->next;printf(“Input the city you want to go: ”);scanf(“%s”,&str);

p=l->next;while(p!=NULL)

{ if(strcmp(p->data.city,str)==0)

{ r[i]=p;i++;

}

p=p->next;

} printf(“nnthe number of record have %dn”,i);for(t=0;t

{ printf(“ndo you want to book it?<1/0>n”);scanf(“%d”,&ch);if(ch == 1)

{

h=(bookMan*)malloc(sizeof(bookMan));printf(“Input your name: ”);scanf(“%s”,&str1);strcpy(h->data.name,str1);printf(“Input your id: ”);scanf(“%s”,&str2);strcpy(h->data.num,str2);printf(“Input your bookNum: ”);scanf(“%d”,&dem);h->data.bookNum=dem;h->next=NULL;v->next=h;

v=h;printf(“nLucky!you have booked a ticket!”);getch();shoudsave=1;

}

} } bookMan*Locate2(bookManLinkk,charfindmess[]){ bookMan*r;

r=k->next;while(r)

{ if(strcmp(r->data.num,findmess)==0)

{ mark=1;return r;

}

r=r->next;

} return 0;} /*修改火車信息*/ voidUpdateInfo(Link l){

Node*p;charfindmess[20],ch;if(!l->next)

{ printf(“nthere isn't record for you to modify!n”);return;

} else

{ QueryTrain(l);if(mark1==0)

{ printf(“nDo you want to modify it?n”);getchar();scanf(“%c”,&ch);if(ch=='y');

{ printf(“nInput the number of the train:”);scanf(“%s”,findmess);

p=Locate1(l,findmess,“num”);if(p)

{ printf(“Input new number of train:”);scanf(“%s”,&p->data.num);printf(“Input new city the train will reach:”);scanf(“%s”,&p->data.city);printf(“Input new time the train take off”);scanf(“%s”,&p->data.takeoffTime);printf(“Input new time the train reach:”);scanf(“%s”,&p->data.receiveTime);printf(“Input new price of the ticket::”);scanf(“%d”,&p->data.price);printf(“Input new number of people who have booked ticket:”);scanf(“%d”,&p->data.bookNum);printf(“nmodifying record is sucessful!n”);shoudsave=1;

} else printf(“tttcan't find the record!”);

}

} else

mark1=0;

} } /*系統(tǒng)給用戶的提示信息*/ voidAdvicedTrains(Link l){

Node*r;charstr[10];int mar=0;

r=l->next;printf(“Iuput the city you want to go: ”);scanf(“%s”,str);while(r)

{ if(strcmp(r->data.city,str)==0&&r->data.bookNum<200)

{ mar=1;printf(“nyou can select the following train!n”);printf(“nnplease select the fourth operation to book the ticket!n”);printTrainInfo(r);

}

r=r->next;

} if(mar==0)printf(“ntttyou can't book any ticket now!n”);} /*保存火車信息*/ voidSaveTrainInfo(Link l){

FILE*fp;

Node*p;int count=0,flag=1;fp=fopen(“c: rain.txt”,“wb”);if(fp==NULL)

{ printf(“the file can't be opened!”);return;

}

p=l->next;while(p)

{ if(fwrite(p,sizeof(Node),1,fp)==1)

{

p=p->next;count++;

} else

{ flag=0;break;

}

} if(flag)

{ printf(“the number of the record which have been saved is %dn”,count);shoudsave=0;

} fclose(fp);} /*保存訂票人的信息*/ voidSaveBookmanInfo(bookManLink k){

FILE*fp;bookMan*p;int count=0,flag=1;fp=fopen(“c:man.txt”,“wb”);if(fp==NULL)

{ printf(“the file can't be opened!”);return;

}

p=k->next;while(p)

{ if(fwrite(p,sizeof(bookMan),1,fp)==1)

{

p=p->next;count++;

} else

{ flag=0;break;

}

} if(flag)

{ printf(“the number of the record which have been saved is %dn”,count);shoudsave=0;

} fclose(fp);}

int main(){

FILE*fp1,*fp2;

Node*p,*r;char ch1,ch2;

Link l;bookManLink k;bookMan*t,*h;intsel;

l=(Node*)malloc(sizeof(Node));l->next=NULL;

r=l;

k=(bookMan*)malloc(sizeof(bookMan));k->next=NULL;

h=k;

fp1=fopen(“c: rain.txt”,“ab+”);if((fp1==NULL))

{ printf(“can't open the file!”);return 0;

} while(!feof(fp1))

{

p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp1)==1)

{ p->next=NULL;r->next=p;

r=p;count1++;

}

} fclose(fp1);

fp2=fopen(“c:man.txt”,“ab+”);if((fp2==NULL))

{ printf(“can't open the file!”);return 0;

}

while(!feof(fp2))

{

t=(bookMan*)malloc(sizeof(bookMan));if(fread(t,sizeof(bookMan),1,fp2)==1)

{ t->next=NULL;h->next=t;

h=t;count2++;

}

} fclose(fp2);while(1)

{ system(“cls”);printInterface();printf(“please choose the operation: ”);scanf(“%d”,&sel);system(“cls”);if(sel==8)

{ if(shoudsave==1)

{ getchar();printf(“nthe file have been changed!do you want to save it(y/n)?n”);scanf(“%c”,&ch1);if(ch1=='y'||ch1=='Y')

{ SaveBookmanInfo(k);SaveTrainInfo(l);

}

} printf(“nThank you!You are welcome toon”);break;

} switch(sel)

{ case 1 : InsertTraininfo(l);break;case 2 : QueryTrain(l);break;case 3 : BookTicket(l,k);break;case 4 : UpdateInfo(l);break;case 5 : AdvicedTrains(l);break;case 6 : SaveTrainInfo(l);SaveBookmanInfo(k);break;case 7 : return 0;

} printf(“nplease press any key to continue.......”);getch();

} return 0;}

下載火車訂票系統(tǒng)部分 uml[推薦]word格式文檔
下載火車訂票系統(tǒng)部分 uml[推薦].doc
將本文檔下載到自己電腦,方便修改和收藏,請勿使用迅雷等下載。
點(diǎn)此處下載文檔

文檔為doc格式


聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻(xiàn)自行上傳,本網(wǎng)站不擁有所有權(quán),未作人工編輯處理,也不承擔(dān)相關(guān)法律責(zé)任。如果您發(fā)現(xiàn)有涉嫌版權(quán)的內(nèi)容,歡迎發(fā)送郵件至:645879355@qq.com 進(jìn)行舉報(bào),并提供相關(guān)證據(jù),工作人員會在5個工作日內(nèi)聯(lián)系你,一經(jīng)查實(shí),本站將立刻刪除涉嫌侵權(quán)內(nèi)容。

相關(guān)范文推薦

    UML 網(wǎng)吧管理系統(tǒng)

    貴州師范大學(xué)職業(yè)技術(shù)學(xué)院 系統(tǒng)名稱: 姓 名: 班 級: 08 專 業(yè): —— UML基礎(chǔ)教程 —— 考 察 報(bào) 告 網(wǎng)吧管理系統(tǒng) 成豪 王建勇 何汶峰 彭健 楊茂科 楊勝文 楊興福 楊家權(quán)......

    UML庫存管理系統(tǒng)

    UML課程設(shè)計(jì) 報(bào)告 設(shè)計(jì)名稱: 庫存管理系統(tǒng)專業(yè)班級: 姓 名: 學(xué) 號: 起止時(shí)間: 成 績 評 定考核 設(shè)計(jì) 設(shè)計(jì) 綜合評 答辯 內(nèi)容 表現(xiàn) 報(bào)告 定成績 成 績 計(jì)算機(jī)科學(xué)與工程系 一......

    數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì) 飛機(jī)訂票系統(tǒng)

    飛機(jī)訂票系統(tǒng) 1. 需求分析描述要求編程解決的問題。以無歧義的陳述說明程序設(shè)計(jì)的任務(wù),強(qiáng)調(diào)的是程序要做什么?明確規(guī)定: (a) 輸入的形式和輸入值的范圍;(b) 輸出的形式;(c) 程......

    數(shù)據(jù)庫課程設(shè)計(jì)+飛機(jī)訂票系統(tǒng)

    飛機(jī)訂票系統(tǒng) 1.概述(設(shè)計(jì)題目與可行性分析) 1.1設(shè)計(jì)題目:飛機(jī)訂票系統(tǒng) 1.2可行性分析 飛機(jī)訂票系統(tǒng)是為機(jī)場工作人員和客戶提供訂票退票等與機(jī)票相關(guān)內(nèi)容的管理系統(tǒng),方便機(jī)場工......

    飛機(jī)訂票系統(tǒng)風(fēng)險(xiǎn)評估

    飛機(jī)訂票系統(tǒng) —項(xiàng)目風(fēng)險(xiǎn)評估報(bào)告 本文檔的范圍和目的 本文主要針對飛機(jī)訂票系統(tǒng)軟件開發(fā)涉及到的風(fēng)險(xiǎn),包括在軟件開發(fā)周期過程中可能出現(xiàn)的風(fēng)險(xiǎn)以及軟件實(shí)施過程中外部......

    火車購票系統(tǒng)UML類圖 時(shí)序圖 狀態(tài)圖 協(xié)作圖 活動圖 對象.[范文大全]

    《UML 面向?qū)ο蠓治觥氛n程 實(shí)踐項(xiàng)目報(bào)告 項(xiàng)目名稱: 網(wǎng)上訂購火車票系統(tǒng) 項(xiàng)目組成員: 學(xué) 號: 班 級: 指導(dǎo) 教師: 2008年 11 月 10 日 目 錄 1 需求分析 ...............................

    UML(ATM系統(tǒng))動態(tài)建模

    實(shí)驗(yàn)3 動態(tài)建模 一、 實(shí)驗(yàn)?zāi)康呐c要求 1 掌握分析ATM系統(tǒng)用例中用例的流程,分析對象之間的交互關(guān)系 2 掌握用UML設(shè)計(jì)參與對象之間的交互,用狀態(tài)圖、時(shí)序圖、協(xié)作圖和活動圖來描......

    門診管理系統(tǒng)UML(合集五篇)

    門診管理系統(tǒng) 第1章 需求分析 1.1系統(tǒng)建設(shè)的意義 隨著社會的發(fā)展,人們的生活節(jié)奏不斷加快,各種突發(fā)事故也頻繁發(fā)生。因此對于醫(yī)護(hù)人員來說提高單位時(shí)間內(nèi)的工作效率顯得原發(fā)重......

主站蜘蛛池模板: 在线观看国产精品日韩av| 天天躁日日躁狠狠躁av麻豆男男| 无码av免费毛片一区二区| 最新在线精品国自产拍视频| 激情按摩系列片aaaa| 亚洲av无码一区二区乱子伦| 国产成人综合久久免费| 国产成人人人97超碰超爽8| 伊人久久精品一区二区三区| 无码加勒比一区二区三区四区| 久久久精品人妻久久影视| 久久久精品妇女99| 亚洲精品成a人在线观看| 国产在线无码一区二区三区视频| 无码欧美成人AAAA三区在线| 久久亚洲欧美国产精品| 亚洲成a∧人片在线播放调教| 亚洲成aⅴ人片久青草影院按摩| 免费无码h肉动漫在线观看| 成av人片一区二区三区久久| 亚洲中久无码永久在线观看软件| 农村欧美丰满熟妇xxxx| 上司人妻互换hd无码中文| 中文字幕丰满乱子无码视频| 亚洲精品1卡2卡三卡4卡乱码| 国产成人亚洲精品无码h在线| 国产成人av大片大片在线播放| 亚洲国产成人乱码| 久久午夜夜伦鲁鲁片免费无码影视| 成人国产一区二区三区精品不卡| 国产免费破外女真实出血视频| 久久亚洲精品中文字幕| 99精品产国品一二三产区| 亚洲成在人网站av天堂| 人妻中出受孕 中文字幕在线| 无码视频在线观看| 精品无码av无码免费专区| 亚洲另类无码专区首页| 国产精品美女乱子伦高潮| 日韩成人免费无码不卡视频| 亚洲精品无码久久久久去q|