university of macau faculty of science and technology computer and information science
DESCRIPTION
University of Macau Faculty of Science and Technology Computer and Information Science. SFTW241 Programming Languages Architecture 2002~2003 Semester II Duration: 2003/4/11~ 2003/6/11. Year2 Class A Group A5 http://hk.geocities.com/sftw241_a5. Bus Route System By A5. - PowerPoint PPT PresentationTRANSCRIPT
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
Bus Route SystemBy A5
Part ISystem Introduction
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
Our targets are Tourists and people who travel by bus
Why did we choose this system?UsefulRealisticConvenientFriendlyExtensible
Idea
Through our system, the user can choose Two different functionsA particular bus path A bus route from a place to another place
Function
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
Input the Starting point Input the Destination The user can select a particular Bus Company Finish the input and send the request
Procedure
The bus routes show on the map Dialog Box shows all the information,
which contains:Bus company nameBus codeBus routeTotal fee
Procedure
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
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
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
Different bus stop The information of the different bus route The company belongs The fee of a particular bus
Data Base
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
Part II Information Support
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
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
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
Part III Interface
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
Dialog
CDialog
CAboutDlg
CBusSearchDlg
CFront
CParticular
Ccomfirm
CResult
CPresult
CTransferResult
Dialog:CBusSearchDlg
CBusSearchDlgOnPaint
OnInitDialog
OnSearch
OnParticular
OnQueryDragIcon
OnReset
Draw
OnSysCommand OnButton
DoDataExchange OnBack
CBusSearchDlg
Method Method
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
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
Method:OnParticular
OnParticular
CParticular
Pinput boxDoModal
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
The rote of the figure
The Figure (Map)
Input
Button ComboBox
Output
Line Colour
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.
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
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
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.
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.
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.
How to display the corresponding bus routes by program? (II)
Bus code coordinates
Bus code Bus codecoordinates coordinates
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.
Let’s read the program code about draw()
Program code
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?
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?
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;
}
Let’s read the program code about OnButton(), CcomfirmDlg.
Read the program
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…
Part IV Kernel
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
Flowchart of Searching Particular Route
PInput
Initialize_busnameInitialize_number
PResult
Interface
ShowparticularInterfaces
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?
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 .
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
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.
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.
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()
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”
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.
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.
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.
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.
Input File
The standard of the input fileStartpoint endpoint company
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
Particular bus input and output Input
PINPUT.txtThe number of the bus route
OutputPRESULT.txtStandard
Company name Cost Number Route
Example
To make you fully understand our algorithm
We will show 4 example to explain our algorithm.
Example 1
Playground to High School
Output 1
Example 2
Output 2
Example 3
Output 3
Example 4
Output 4
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
Part V Web Site
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
Part VI Support For Client
By Simon
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
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.
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
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.
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
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
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.
Part VII Web Site support
by Jacky
Part VIII Evaluation of Program
By Solomon
Kernel part
Running Time Algorithms The capacity of program Data structure
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)
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
Evaluation
Team work: James & Justin : design Kernel function Fenny & Stella: Design Interface Daniel : input information of system Their working shared clearly and fairly
Conclusion of Our Consultant
~The End~(Our Consultant Part)
Part IXConclusion
Part X Q & A