Object Oriented Design Peter McClone. Goals To be able to: Identify how an object contributes to a...
-
Upload
alvin-brooks -
Category
Documents
-
view
213 -
download
0
Transcript of Object Oriented Design Peter McClone. Goals To be able to: Identify how an object contributes to a...
Goals
To be able to: Identify how an object contributes to a problem
solution Identify what classes are needed to solve a problem Describe how objects work together to solve a
problem Group objects with similar attributes into one class Distinguish between instances and classes Draw the object diagram for a description given
Location: Mootown Airport
Mootown is a small city in rural Wisconsin. The Mootown City Council has started discussions about building an airport.
The Mootown City Council contracted with C. Thomas Wu Consulting Inc. to design a computer model of the airport. The City Council has a general description of the initial airport design from which we will base our design.
General Design The airport is small. It has one runway and two ticket counters. Each ticket counter controls two gates where passengers can board
their flights. Each gate can only support one airplane at a time. Passengers enter the airport, go to a ticket counter to check-in,
surrendering a ticket to a ticket counter employee and receiving back a boarding pass. After receiving a boarding pass, they go to a gate where they wait.
When the airplane is ready, the passengers board their flight. When all of the passengers have boarded, the airplane taxis away from the gate to the runway, where it will take off to travel to Corntown airport in Iowa, Wheattown airport in Kansas, and/or Beettown airport in Minnesota.
Ticket Counter #1 serves Gurnsey Express and Ticket Counter #2 serves Holstein Airways. Ticket Counter #1 has two Gates, Gate A and Gate B.
Ticket Counter #2 controls Gate C and Gate D. The two Ticket Counters also have various employees working at them. Jennifer and Jim both work at Ticket Counter #1; Tom and Theresa work at Ticket Counter #2.
Pulling out the nouns: The airport is small. It has one runway and two ticket counters. Each ticket counter controls two gates where passengers can board
their flights. Each gate can only support one airplane at a time. Passengers enter the airport, go to a ticket counter to check-in,
surrendering a ticket to a ticket counter employee and receiving back a boarding pass. After receiving a boarding pass, they go to a gate where they wait.
When the airplane is ready, the passengers board their flight. When all of the passengers have boarded, the airplane taxis away from the gate to the runway, where it will take off to travel to Corntown airport in Iowa, Wheattown airport in Kansas, and/or Beettown airport in Minnesota.
Ticket Counter #1 serves Gurnsey Express and Ticket Counter #2 serves Holstein Airways. Ticket Counter #1 has two Gates, Gate A and Gate B.
Ticket Counter #2 controls Gate C and Gate D. The two Ticket Counters also have various employees working at them. Jennifer and Jim both work at Ticket Counter #1; Tom and Theresa work at Ticket Counter #2.
Creating the model
Our Nouns: Runway, Ticket Counter, Gate, Passenger, Flight, Airplane, Employee,
Ticket, Boarding Pass Each noun in this list will be a class in our model of the Mootown
Airport. Each of these classes will have one or more instances (also called
objects) in our model. Example:
Class: Employee Instance: Tom, Theresa, Jim, Jennifer Class: Ticket Counter Ticket Counter #1, Ticket Counter #2
Leaving things out
What are we missing? Plants, carpet, air … etc.
Only include what is necessary for our model. Careful consideration must be given to what is
needed to obtain a solution to the given problem AND what may be needed to solve future, similar problems.
There are situations where a lot of detail is needed
Data Members
What sort of information is it important to associate with each class?
Let’s go through each class
Runway
length - number of meters
direction - the compass heading the runway faces (north, south, etc.)
Ticket Couner
airline - name of the airline the ticket counter serves
employees - number of employees working at the counter
gates - number of gates the ticket counter controls
Gate
plane - the flight number of the plane currently outside, if there is one
name – the name of the gate
Passenger
name - the passenger's first and last name ticket – a ticket for his/her flight boardingPass - a boarding pass for
his/her flight
Flight
airline - name of the airline the flight belongs to
number - flight number that identifies what flight it is
destination - the flight's next stop departure - time the flight is scheduled to
leave arrival - time the flight is scheduled to land
at its destination
Airplane
type - what kind of plane it is (Example: 747)
airline - what airline it belongs to capacity - the number of people that the
plane can hold
Ticket
planeNumber - what plane the ticket is for rowNumber - what on the plane the ticket
is for seatNumber - what seat the ticket is for
General Design (2nd) The airport is small. It has one runway and two ticket counters. Each ticket counter controls two gates where passengers can board
their flights. Each gate can only support one airplane at a time. Passengers enter the airport, go to a ticket counter to check-in,
surrendering a ticket to a ticket counter employee and receiving back a boarding pass. After receiving a boarding pass, they go to a gate where they wait.
When the airplane is ready, the passengers board their flight. When all of the passengers have boarded, the airplane taxis away from the gate to the runway, where it will take off to travel to Corntown airport in Iowa, Wheattown airport in Kansas, and/or Beettown airport in Minnesota.
Ticket Counter #1 serves Gurnsey Express and Ticket Counter #2 serves Holstein Airways. Ticket Counter #1 has two Gates, Gate A and Gate B.
Ticket Counter #2 controls Gate C and Gate D. The two Ticket Counters also have various employees working at them. Jennifer and Jim both work at Ticket Counter #1; Tom and Theresa work at Ticket Counter #2.
General Design (2nd) The airport is small. It has one runway and two ticket counters. Each ticket counter controls two gates where passengers can board
their flights. Each gate can only support one airplane at a time. Passengers enter the airport, go to a ticket counter to check-in,
surrendering a ticket to a ticket counter employee and receiving back a boarding pass. After receiving a boarding pass, they go to a gate where they wait.
When the airplane is ready, the passengers board their flight. When all of the passengers have boarded, the airplane taxis away from the gate to the runway, where it will take off to travel to Corntown airport in Iowa, Wheattown airport in Kansas, and/or Beettown airport in Minnesota.
Ticket Counter #1 serves Gurnsey Express and Ticket Counter #2 serves Holstein Airways. Ticket Counter #1 has two Gates, Gate A and Gate B.
Ticket Counter #2 controls Gate C and Gate D. The two Ticket Counters also have various employees working at them. Jennifer and Jim both work at Ticket Counter #1; Tom and Theresa work at Ticket Counter #2.
What isn’t mentioned?
Land - Airplane makes contact with the runway, slows down, and eventually stops
Others?
What action belongs to what class?
Runway
Data members: Length – number of meters direction - the compass heading the runway
faces (north, south, etc.) Methods:
None
Ticket Couner
Data members: airline - name of the airline the ticket counter
serves employees - number of employees working at
the counter gates - number of gates the ticket counter
controls Methods:
None
Gate
Data Members: plane - the flight number of the plane currently
outside, if there is one name – the name of the gate
Methods: None
Passenger
Data Members: name - the passenger's first and last name ticket – a ticket for his/her flight boardingPass - a boarding pass for his/her flight
Methods: enterAirport - proceed through the door to the airport
facility wait - sit, stand, or pace until the correct boarding call is
announced surrenderTicket - give a ticket to an airport employee goToGate - proceed to the gate indicated on a boarding
pass boardPlane - get on the plane
Flight
Data Members: airline - name of the airline the flight belongs to number - flight number that identifies what flight it is destination - the flight's next stop departure - time the flight is scheduled to leave arrival - time the flight is scheduled to land at its
destination
Methods: None
Airplane
Data Members: type - what kind of plane it is (Example: 747) airline - what airline it belongs to capacity - the number of people that the plane can hold
Methods: taxi - plane moves from the gate to the start of the
runway takeOff - plane accelerates down the runway and lifts
off the ground land - plane makes contact with the runway and
decelerates until it reaches the end of the runway
Employee
Data Members: name - first and last name IDNumber - identification number
Methods: receiveTicket - obtain a ticket from a
passenger and give a boarding pass
Ticket
Data Members: planeNumber - what plane the ticket is for rowNumber - what on the plane the ticket is
for seatNumber - what seat the ticket is for
Methods: None
Boarding Pass
Data Members: name - name of the passenger who holds it gate - gate the pass is for
Methods: None