Download presentation
Presentation is loading. Please wait.
Published byDwain Austin Modified over 8 years ago
1
SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer and Information Science Year2 Class A Group A5 http://hk.geocities.com/sftw241_a5
2
Bus Route System By A5
3
Part I System Introduction
4
After these duration, we finish our program — Bus Route System In this part, we will tell you the problem’s information again, which is: Idea Function Procedure Technique Introduction
5
Our targets are Tourists and people who travel by bus Why did we choose this system? Useful Realistic Convenient Friendly Extensible Idea
6
Through our system, the user can choose Two different functions A particular bus path A bus route from a place to another place Function
7
At first we would like to choose a real city, such as Macau, to implement our system. Afterward we found that the database is too enormous to control. Therefore, we decide a simulated city A5 to execute this program. Function
8
Input the Starting point Input the Destination The user can select a particular Bus Company Finish the input and send the request Procedure
9
The bus routes show on the map Dialog Box shows all the information, which contains: Bus company name Bus code Bus route Total fee Procedure
10
Another function is searching a Particular bus path Select bus number, No.1 for example Shows the whole particular bus route on the screen A dialog box is also provided Procedure
11
A special situation: there may be no bus can reach the selected point directly, so the user must Transfer to other bus It is a trouble problem for the tourists. Our system can also help them to handle it. Procedure
12
In this case, the system will tell the user he/she should transfer to other bus in which bus stop The system adds more information in the dialog box. Such as The transfer station The transfer route Which bus should be traveled by Single fee and total fee
13
Different bus stop The information of the different bus route The company belongs The fee of a particular bus Data Base
14
Individual bus’ route data link-list Connect bus stop to bus stop Make the data meaningful Running time O(N) Collection of bus’ route data Hash table easy to handle Guarantee the running time still fix in O(N) Data Structure
15
Part II Information Support
16
Information Support We have make a virtual bus route network There has 4 routes on this city Each bus stop of a route will indicate one number Each bus stop has its XY coordinate There must has some intersection bus stops so each of them will have several indicate numbers
17
Text File We have make a virtual bus route network There has 4 routes on this city Each bus stop of a route will indicate one number Each bus stop has its XY coordinate There must has some intersection bus stops so each of them will have several indicate numbers
18
Text File For interface & kernel read and write files: INPUT.txt for interface send the input start and input end bus stop’s name to the kernel Send the Result.txt and XY.txt files to interface when kernel find the result PINPUT.txt for interface send the particular input bus route number to the kernel Send the PRESULT.txt and XY.txt files to interface when kernel get the result
19
Part III Interface
20
Software Microsoft Visual C++ version 6.0 MFC AppWizard (exe) The Microsoft Foundation Class Library (MFC) provides much of the code necessary for managing windows, menus, and dialog boxes performing basic input/output storing collections of data objects MFC shortens development time and gives easy access to "hard to program" user-interface elements and technologies
21
Dialog CDialog CAboutDlg CBusSearchDlg CFront CParticular Ccomfirm CResult CPresult CTransferResult
22
Dialog: CBusSearchDlg CBusSearchDlg OnPaint OnInitDialog OnSearch OnParticular OnQueryDragIcon OnReset Draw OnSysCommand OnButton DoDataExchange OnBack CBusSearchDlg Method
23
Dialog: CBusSearchDlg OnSearch: The user enters the starting point, end point and the company name, then search the bus route OnParticular: The user inputs the bus code and search a particular route OnReset: Initialize all the input and all text file OnBack: Return to the start page
24
Method: OnSearch OnSearchResult box CResultCTransferResult TransferResult box DoModal Object When we run OnSearch, the input will be written into INPUT.txt. After finish the kernel part, we can get the result in the RESULT.txt. According to the state, the model of result box will be different
25
Method: OnParticular OnParticular CParticular Pinput box DoModal Send P_choose Presult box CPresult DoModal When we run OnParticular, a particular input box will show. After it gets the bus code, it changes P_choose which is a global variable. Then write it into PINPUT.txt According to PRESULT.txt, the result will show in the Particular result box
26
The rote of the figure The Figure (Map) Input ButtonComboBox Output LineColour
27
As Output 1. How to draw a line? 2. How to draw a line in front of a picture? 3. How to display the corresponding bus routes by program? 4. How to display the line in different colors? 5. How to separate the first bus and the second bus by different colors.
28
How to draw a line? (I) Must include “MFC” (Microsoft Foundation Class). GDI (Graphic Device Interface) of MFC In our program, we had use “CPen” to draw the lines. CGdiObject CBitmapCBrushCFontCPaletteCPenCRgn
29
How to draw a line? (II) DC is a region for drawing. In our program, we had use “CClientDC” since we need the “Client” region of the Windows Screen for us to draw the lines. CDC CClientDCCMetaFileDCCPaintDCCWindowDC
30
How to draw a line? (III) CPaintDC dc(this); CPen newPen; newPen.CreatePen(PS_DASH,3,RGB(0,0,225)); CPen *oldPen; oldPen=dc.SelectObject(&newPen); int x1= 0, y1= 0, x2= 300, y2= 300; dc.MoveTo(x1,y1); dc.LineTo(x2,y2); dc.SelectObject(oldPen); But can’t display in front of the picture.
31
How to draw a line on a picture? (I) CClientDC dc(this); CPen newPen; newPen.CreatePen(PS_DASH,3,RGB(0,0,225)); CPen *oldPen; oldPen=dc.SelectObject(&newPen); int x1= 0, y1= 0, x2= 300, y2= 300; dc.MoveTo(x1,y1); dc.LineTo(x2,y2); dc.SelectObject(oldPen); Now, the line can be displayed in front of the picture.
32
How to display the corresponding bus routes by program? (I) Reading the data ( the coordinates of the bus stops) form “XY.txt” “XY.txt” is created by the searching engine.
33
How to display the corresponding bus routes by program? (II) Bus code coordinates Bus code coordinates
34
How to know the coordinate of the points? We can check the pixel (the coordinates of the point) on the picture by using some graphical software. E.g. Paint, PhotoShop, Paint Shop Pro, etc. Plus the starting coordinates of the picture on the Dialog Base.
35
Let’s read the program code about draw() Program code
36
As Input 1. How to make the button? 2. How to hide the button at the beginning? After it was clicked, display it? 3. How to know the button which is selected is the starting point or the destination? 4. How to transfer the starting point and the destination to the ComboBox after we select by clicking button?
37
Solution: Output a dialog for the users to choose. Set a global variable C_Choose to determine the Starting Point, the Destination. Initialize: C_Choose = 0 OnOK() The Starting Point: C_Choose = 1 The Destination : C_Choose = 2 OnCANCEL() C_Choose = 0 How to transfer input to the ComboBox?
38
if(C_Choose==1) { m_StartCtrl.SelectString(1,"Hospital"); C_Choose = 0; // Reset it } else if( C_Choose==2) { m_DestinationCtrl.SelectString(1,"Hospital"); C_Choose = 0; }
39
Let’s read the program code about OnButton(), CcomfirmDlg. Read the program
40
The Expected interface and the Non-Solving Problems In the result message box, we expect the text of the bus routes can be colored according to the corresponded bus code. In the result message box, we expect the bus picture can be shown and exchanged by program. If the Bus Code is not 0,1,2,3, the draw( ) function must be modified and be more difficult. E.g. 33, 12A…
41
Part IV Kernel
42
Flowchart of Searching Bus Route Initialize_busname XY.txt Initialize for Digital Search intersection Show_route Result.txt Interface Search start Input Interfaces Search end
43
Flowchart of Searching Particular Route PInput Initialize_busname Initialize_number PResult Interface Showparticular Interfaces
44
Initializing Method initialize_code() Use to initialize the digital data for algorithm We use the data for searching the bus route Because our system need the digital number for the searching algorithm. Every bus stops has it unique digital code itself, except intersection bus stops. Each of them has two digital codes to stand for it. WHY do the intersection bus stops have two digital codes?
45
Initializing Initialize_busname( ) Initialize the (string) name of the bus stops Initialize the XY-Coordinates of each bus stops We use these data for outputting to the text files for the interface to show the bus route.
46
Input Input() Get the useful data from the file that create by the interface 3 items of information is needed Starting bus stop Destination bus stop Company we will store them in the corresponding fields for the searching
47
Searching start point searchstart() Use the start point from the input file Use it to find the bus route number and record it in the field “recordstart” According the recordstart, we find the company which the bus route belongs to. At the same time, we use the field “selectcompany” compare with the corresponding company.
48
Searching start point searchstart() Use the start point from the input file Use it to find the bus route number and record it in the field “recordstart” According the recordstart, we find the company which the bus route belongs to. At the same time, we use the field “selectcompany” compare with the corresponding company.
49
Searching end point Searchend() Use the end point from the input file Use it to find the bus route number and record it in the field “recordend” According the recordend, we find the company which the bus route belongs to. At the same time, we use the field “selectcompany” compare with the corresponding company. We will use the result of the seachstart and compare with the result of the search end to judge whether it exist bus route for the user requirement and return the value for showroute()
50
Searching intersection Search_intersection() looking for the transfering bus stop According to the result from searchstart and searchend, we use the recordstart and recordend to open the file that content the intersection point between routes and its two digital codes. Store them in the fields “transferbusstop”
51
Show route Show_route() This is the most important method in the class bus. We use it to search the bus route and show the result. In the show, we have two cases to handle, and in each case we also have two sub- case to handle.
52
Show route The first case the starting bus stop and the ending bus stop is belong to the same bus route. The second case the starting bus stop and the ending bus stop is belong to different bus routes.
53
Show route Two sub-case Because the bus system has two directions, we need to handle this problem that we can show the route directly or reversely. In each case we will put the result in the output files “RESULT.txt”, “XY.txt” immediately. The interface will read the file to display the bus route.
54
Show particular bus route Showparticular() This is a specific method for the interface when the user ’ s requirement want to see the detail of a particular bus route. According to the “ PINPUT.txt ” text file to get the route number then we put the result in the “ PRESULT.txt ” text file. The interface will get the result from the text file and show the bus route information.
55
Input File The standard of the input file Startpoint endpoint company
56
Output file The standard of the output file Validity bus company company name of the starting bus Company name of the ending bus Cost of starting bus Cost of ending bus Total cost Bus number of the starting bus Bus number of the ending bus Bus route
57
Particular bus input and output Input PINPUT.txt The number of the bus route Output PRESULT.txt Standard Company name Cost Number Route
58
Example To make you fully understand our algorithm We will show 4 example to explain our algorithm.
59
Example 1 Playground to High School
60
Output 1
61
Example 2
62
Output 2
63
Example 3
64
Output 3
65
Example 4
66
Output 4
67
Combine Since we divided our work into Kernel part and Interface, after finishing these two parts, we must combine them to be one program The Kernel part only has one class, it is quite easy to add into the Interface The names of text files are the same
68
Part V Web Site
69
Web Site Target For all the classmates to know what we have done, the important things it is one of the way for our client and consultant to communicate with us Content It contains client and consultant page, project page, record page and some pages else
70
Part VI Support For Client By Simon
71
Base knowledge Support Prepare for the final project: First, we teach our client the base knowledge for C++ Four lessons and labs Give assignment for each class Answer their question about the course
72
Advance Support I After they decided the final project: we had a meeting with them immediately According to their project,we collect some important knowledge add one more lesson to review all useful knowledge and teach them the GUI. built a guest book for them to ask questions view the guest book two days one time.
73
Advance Support II Before the programming: We support them some software: Visual C++.NET they decided to use the Visual C++ which is more easier to use. We discuss the data structure of the kernel Choose the best algorithm
74
Programming Support I Implement program: we checked their programming progress three days a time Meeting with them frequently. collect the problem and show the solution or suggestion on the web.
75
Programming Support II Technique and actual problem : Can not understand the reason clearly by our web support. We assist them by show and explain them some relative program
76
Programming Support III Difficult problem: we could’t solve the question soon we gave other support to help them. (reference web, reference book) asking some classmates for help
77
Programming Support IV Compile & Debug the project : When they compiled the program, the interface and kernel function collided We help them to checked the source code and solve the problem together.
78
Part VII Web Site support by Jacky
79
Part VIII Evaluation of Program By Solomon
80
Kernel part Running Time Algorithms The capacity of program Data structure
81
Interface part Could communicate easier with user or not Could easy to understand by user or not The expression of information is clear or not Could easy to operating by user or not Add some place for advertisement (suggestion)
82
Latent Capacity Be useful for bus stop Have a big market in big city Have a big market in tourism city The cost of machine is too much
83
Evaluation Team work: James & Justin : design Kernel function Fenny & Stella: Design Interface Daniel : input information of system Their working shared clearly and fairly
84
Conclusion of Our Consultant
85
~The End~ (Our Consultant Part)
86
Part IX Conclusion
87
Part X Q & A
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.