university of macau faculty of science and technology computer and information science

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 and Information Science Year2 Class A Group A5 http://hk.geocities.com/sftw241_a5

Upload: prem

Post on 19-Jan-2016

26 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 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

University of MacauFaculty of Science and TechnologyComputer and Information Science

Year2 Class A

Group A5 http://hk.geocities.com/sftw241_a5

Page 2: University of Macau Faculty of Science and Technology Computer and Information Science

Bus Route SystemBy A5

Page 3: University of Macau Faculty of Science and Technology Computer and Information Science

Part ISystem Introduction

Page 4: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Our targets are Tourists and people who travel by bus

Why did we choose this system?UsefulRealisticConvenientFriendlyExtensible

Idea

Page 6: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

The bus routes show on the map Dialog Box shows all the information,

which contains:Bus company nameBus codeBus routeTotal fee

Procedure

Page 10: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Different bus stop The information of the different bus route The company belongs The fee of a particular bus

Data Base

Page 14: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part II Information Support

Page 16: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part III Interface

Page 20: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Dialog

CDialog

CAboutDlg

CBusSearchDlg

CFront

CParticular

Ccomfirm

CResult

CPresult

CTransferResult

Page 22: University of Macau Faculty of Science and Technology Computer and Information Science

Dialog:CBusSearchDlg

CBusSearchDlgOnPaint

OnInitDialog

OnSearch

OnParticular

OnQueryDragIcon

OnReset

Draw

OnSysCommand OnButton

DoDataExchange OnBack

CBusSearchDlg

Method Method

Page 23: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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

Page 26: University of Macau Faculty of Science and Technology Computer and Information Science

The rote of the figure

The Figure (Map)

Input

Button ComboBox

Output

Line Colour

Page 27: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

How to display the corresponding bus routes by program? (II)

Bus code coordinates

Bus code Bus codecoordinates coordinates

Page 34: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Let’s read the program code about draw()

Program code

Page 36: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Let’s read the program code about OnButton(), CcomfirmDlg.

Read the program

Page 40: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part IV Kernel

Page 42: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Flowchart of Searching Particular Route

PInput

Initialize_busnameInitialize_number

PResult

Interface

ShowparticularInterfaces

Page 44: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Input File

The standard of the input fileStartpoint endpoint company

Page 56: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Particular bus input and output Input

PINPUT.txtThe number of the bus route

OutputPRESULT.txtStandard

Company name Cost Number Route

Page 58: University of Macau Faculty of Science and Technology Computer and Information Science

Example

To make you fully understand our algorithm

We will show 4 example to explain our algorithm.

Page 59: University of Macau Faculty of Science and Technology Computer and Information Science

Example 1

Playground to High School

Page 60: University of Macau Faculty of Science and Technology Computer and Information Science

Output 1

Page 61: University of Macau Faculty of Science and Technology Computer and Information Science

Example 2

Page 62: University of Macau Faculty of Science and Technology Computer and Information Science

Output 2

Page 63: University of Macau Faculty of Science and Technology Computer and Information Science

Example 3

Page 64: University of Macau Faculty of Science and Technology Computer and Information Science

Output 3

Page 65: University of Macau Faculty of Science and Technology Computer and Information Science

Example 4

Page 66: University of Macau Faculty of Science and Technology Computer and Information Science

Output 4

Page 67: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part V Web Site

Page 69: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part VI Support For Client

By Simon

Page 71: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Part VII Web Site support

by Jacky

Page 79: University of Macau Faculty of Science and Technology Computer and Information Science

Part VIII Evaluation of Program

By Solomon

Page 80: University of Macau Faculty of Science and Technology Computer and Information Science

Kernel part

Running Time Algorithms The capacity of program Data structure

Page 81: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

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: University of Macau Faculty of Science and Technology Computer and Information Science

Conclusion of Our Consultant

Page 85: University of Macau Faculty of Science and Technology Computer and Information Science

~The End~(Our Consultant Part)

Page 86: University of Macau Faculty of Science and Technology Computer and Information Science

Part IXConclusion

Page 87: University of Macau Faculty of Science and Technology Computer and Information Science

Part X Q & A