sftw241 programming languages architecture 2002~2003 semester ii duration: 2003/4/11~ 2003/6/11...
DESCRIPTION
Part I System IntroductionTRANSCRIPT
![Page 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](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/1.jpg)
SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11
University of MacauFaculty of Science and TechnologyComputer and Information Science
Year2 Class A
Group A5 http://hk.geocities.com/sftw241_a5
![Page 2: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/2.jpg)
Bus Route SystemBy A5
![Page 3: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/3.jpg)
Part ISystem Introduction
![Page 4: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/4.jpg)
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
![Page 5: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/5.jpg)
Our targets are Tourists and people who travel by bus
Why did we choose this system?UsefulRealisticConvenientFriendlyExtensible
Idea
![Page 6: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/6.jpg)
Through our system, the user can choose Two different functionsA particular bus path A bus route from a place to another place
Function
![Page 7: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/7.jpg)
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
![Page 8: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/8.jpg)
Input the Starting point Input the Destination The user can select a particular Bus Company Finish the input and send the request
Procedure
![Page 9: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/9.jpg)
The bus routes show on the map Dialog Box shows all the information,
which contains:Bus company nameBus codeBus routeTotal fee
Procedure
![Page 10: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/10.jpg)
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
![Page 11: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/11.jpg)
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
![Page 12: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/12.jpg)
Procedure
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
![Page 13: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/13.jpg)
Different bus stop The information of the different bus route The company belongs The fee of a particular bus
Data Base
![Page 14: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/14.jpg)
Individual bus’ route data link-list
Connect bus stop to bus stop Make the data meaningful Running time O(N)
Collection of bus’ route dataHash table
easy to handle Guarantee the running time still fix in O(N)
Data Structure
![Page 15: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/15.jpg)
Part II Information Support
![Page 16: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/16.jpg)
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
![Page 17: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/17.jpg)
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
![Page 18: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/18.jpg)
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
![Page 19: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/19.jpg)
Part III Interface
![Page 20: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/20.jpg)
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
![Page 21: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/21.jpg)
Dialog
CDialog
CAboutDlg
CBusSearchDlg
CFront
CParticular
Ccomfirm
CResult
CPresult
CTransferResult
![Page 22: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/22.jpg)
Dialog:CBusSearchDlg
CBusSearchDlgOnPaint
OnInitDialog
OnSearch
OnParticular
OnQueryDragIcon
OnReset
Draw
OnSysCommand OnButton
DoDataExchange OnBack
CBusSearchDlg
Method Method
![Page 23: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/23.jpg)
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
![Page 24: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/24.jpg)
Method:OnSearch
OnSearchResult box
CResultCTransferResult
TransferResult boxDoModal DoModal
Object 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
![Page 25: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/25.jpg)
Method:OnParticular
OnParticular
CParticular
Pinput boxDoModalSend
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
![Page 26: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/26.jpg)
The rote of the figure
The Figure (Map)
Input
Button ComboBox
Output
Line Colour
![Page 27: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/27.jpg)
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.
![Page 28: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/28.jpg)
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
CBitmap CBrush CFont CPalette CPen CRgn
![Page 29: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/29.jpg)
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
CClientDC CMetaFileDC CPaintDC CWindowDC
![Page 30: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/30.jpg)
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.
![Page 31: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/31.jpg)
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 bedisplayed in front of the picture.
![Page 32: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/32.jpg)
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.
![Page 33: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/33.jpg)
How to display the corresponding bus routes by program? (II)
Bus code coordinates
Bus code Bus codecoordinates coordinates
![Page 34: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/34.jpg)
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.
![Page 35: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/35.jpg)
Let’s read the program code about draw()
Program code
![Page 36: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/36.jpg)
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?
![Page 37: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/37.jpg)
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?
![Page 38: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/38.jpg)
How to transfer input to the ComboBox?
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;
}
![Page 39: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/39.jpg)
Let’s read the program code about OnButton(), CcomfirmDlg.
Read the program
![Page 40: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/40.jpg)
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…
![Page 41: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/41.jpg)
Part IV Kernel
![Page 42: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/42.jpg)
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
![Page 43: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/43.jpg)
Flowchart of Searching Particular Route
PInput
Initialize_busnameInitialize_number
PResult
Interface
ShowparticularInterfaces
![Page 44: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/44.jpg)
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?
![Page 45: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/45.jpg)
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 .
![Page 46: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/46.jpg)
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
![Page 47: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/47.jpg)
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.
![Page 48: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/48.jpg)
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.
![Page 49: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/49.jpg)
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()
![Page 50: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/50.jpg)
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”
![Page 51: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/51.jpg)
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.
![Page 52: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/52.jpg)
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.
![Page 53: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/53.jpg)
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.
![Page 54: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/54.jpg)
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.
![Page 55: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/55.jpg)
Input File
The standard of the input fileStartpoint endpoint company
![Page 56: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/56.jpg)
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
![Page 57: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/57.jpg)
Particular bus input and output
Input PINPUT.txtThe number of the bus route
OutputPRESULT.txtStandard
Company name Cost Number Route
![Page 58: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/58.jpg)
Example
To make you fully understand our algorithm
We will show 4 example to explain our algorithm.
![Page 59: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/59.jpg)
Example 1
Playground to High School
![Page 60: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/60.jpg)
Output 1
![Page 61: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/61.jpg)
Example 2
![Page 62: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/62.jpg)
Output 2
![Page 63: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/63.jpg)
Example 3
![Page 64: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/64.jpg)
Output 3
![Page 65: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/65.jpg)
Example 4
![Page 66: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/66.jpg)
Output 4
![Page 67: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/67.jpg)
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
![Page 68: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/68.jpg)
Part V Web Site
![Page 69: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/69.jpg)
Web Site
TargetFor 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
![Page 70: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/70.jpg)
Part VI Support For Client
By Simon
![Page 71: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/71.jpg)
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
![Page 72: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/72.jpg)
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.
![Page 73: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/73.jpg)
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
![Page 74: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/74.jpg)
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.
![Page 75: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/75.jpg)
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
![Page 76: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/76.jpg)
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
![Page 77: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/77.jpg)
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.
![Page 78: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/78.jpg)
Part VII Web Site support
by Jacky
![Page 79: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/79.jpg)
Part VIII Evaluation of Program
By Solomon
![Page 80: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/80.jpg)
Kernel part
Running Time Algorithms The capacity of program Data structure
![Page 81: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/81.jpg)
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)
![Page 82: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/82.jpg)
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
![Page 83: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/83.jpg)
Evaluation
Team work: James & Justin : design Kernel function Fenny & Stella: Design Interface Daniel : input information of system Their working shared clearly and fairly
![Page 84: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/84.jpg)
Conclusion of Our Consultant
![Page 85: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/85.jpg)
~The End~(Our Consultant Part)
![Page 86: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/86.jpg)
Part IXConclusion
![Page 87: SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11 University of Macau Faculty of Science and Technology Computer](https://reader034.vdocuments.us/reader034/viewer/2022051302/5a4d1b497f8b9ab0599a4a1c/html5/thumbnails/87.jpg)
Part X Q & A