1 / 87

University of Macau Faculty of Science and Technology Computer and Information Science

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.

prem
Download Presentation

University of Macau Faculty of Science and Technology Computer and Information Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. Bus Route SystemBy A5

  3. Part ISystem 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. Function • Through our system, the user can choose Two different functions • A particular bus path • A bus route from a place to another place

  7. 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.

  8. Procedure • Input the Starting point • Input the Destination • The user can select a particular Bus Company • Finish the input and send the request

  9. Procedure • The bus routes show on the map • Dialog Box shows all the information, which contains: • Bus company name • Bus code • Bus route • Total fee

  10. 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

  11. 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.

  12. 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

  13. Data Base • Different bus stop • The information of the different bus route • The company belongs • The fee of a particular bus

  14. Data Structure • 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)

  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. CPresult Ccomfirm CAboutDlg CDialog CTransferResult CParticular CBusSearchDlg CResult CFront Dialog

  22. CBusSearchDlg OnSearch OnInitDialog OnParticular OnReset OnPaint CBusSearchDlg OnBack DoDataExchange OnButton OnSysCommand Draw OnQueryDragIcon Method Method Dialog:CBusSearchDlg

  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. CTransferResult CResult DoModal DoModal Result box OnSearch TransferResult box Object Object Method:OnSearch • 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. CParticular Pinput box DoModal Send P_choose OnParticular Presult box DoModal CPresult Method:OnParticular • 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) Output Input Line Colour Button ComboBox

  27. As Output • How to draw a line? • How to draw a line in front of a picture? • How to display the corresponding bus routes by program? • How to display the line in different colors? • 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 CBitmap CBrush CFont CPalette CPen CRgn

  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 CClientDC CMetaFileDC CPaintDC CWindowDC

  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 bedisplayed 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 Bus code coordinates 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 • How to make the button? • How to hide the button at the beginning? After it was clicked, display it? • How to know the button which is selected is the starting point or the destination? • How to transfer the starting point and the destination to the ComboBox after we select by clicking button?

  37. How to transfer input to the ComboBox? • 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

  38. 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; }

  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. Interfaces Input Search start Interface Flowchart of Searching Bus Route Search end

  43. Initialize_busname PInput Flowchart of Searching Particular Route

  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”

More Related