160 likes | 426 Vues
Object-oriented Analysis and Design. Phases of the Project. Requirements Document. Object Model Diagram. State Transition Diagrams. Component Construction. Requirements Document.
E N D
Object-oriented Analysis and Design Phases of the Project Requirements Document Object Model Diagram State Transition Diagrams Component Construction
Requirements Document The Corey sisters have a privately-owned alley with a closed spar or turning lane at one end. The sisters plan to use this alley as a parking lot. The lot will hold a maximum of five cars in single file. Cars arrive at one end of the alley, enter at the back, and leave from the front. The spar is used to temporarily hold cars from the front of the line when a car from the middle or end of the line is set to leave. The capacity of the spar is one car less than the capacity of the lot. When the departing car has left, cars from the spar are moved back to the lot and placed in their previous position. All cars that were behind the departed car are moved up one position to allow room for new entries. When the lot is full newly arriving cars will have to find parking elsewhere. A lot simulation will exhibit the working of this lot with cars writing messages showing the times in which they enter and leave the lot or when they arrive and find the lot full.
Requirements Document The Corey sistershave a privately-owned alley with a closed spar or turninglane at one end. The sistersplan to use this alley as a parkinglot. The lotwill hold a maximum of five cars in single file. Carsarrive at one end of the alley, enterat the back, and leave from the front. The sparis usedto temporarily holdcars from the front of the line when a car from the middle or end of the line is set to leave. The capacityof thesparis one car less than the capacityof thelot. When the departing car has left, carsfrom thesparare moved back to the lot and placed in their previousposition. All cars that were behind the departed car are movedupone position to allow room for new entries. When the lotis full newly arriving carswill have to find parking elsewhere. A lotsimulationwillexhibit the working of this lot with carswritingmessages showing the times in which they enter and leave the lot or when they arrive and find the lot full.
Nouns (or noun phrases Sisters (irrelevant) Lot (same as alley and parking lot) Car End, back, front, position (attributes of Lot) Spar Capacity (attribute of Lot and Spar) LotSimulation (to be called LotSim) Message (can be implemented as a string) Arrive/depart time (attributes of car)
Object (Class) Interaction Subject Verb Phrase Object Lot will hold (max of 5) Cars Cars enter (back of) Lot Cars leave (front of) Lot Lot uses Spar Spar holdsCars LotSim exhibits (working of) Lot Cars write Messages
Diagram of the Parking Lot Entry Road Lot Spar Exit Road
Object Model Diagram generates LotSim shows uses holds Lot Spar Car enter leave holds
Design Phase – Refine Object Model LotSim generates Car list enter(Car) leave(Car) Lot Car double arrTime double depTime String name Car list int capacity
Design Phase – State Transition Diagrams enter enter enter enter enter enter start 5 0 1 3 4 2 leave leave leave leave leave isFull == TRUE * States of Lot objects – maxCars = 5 * IsFull tested on each state
Class Lot Lot Car list int capacity enter (Car c) leave(Car c) boolean isFull( ) Lot ( ) Messages received from LotSim
Design Phase – State Transition Diagrams parked leave park newCar String name double arrTime double depTime discarded Start balk State Diagram for Car Objects
Class Car Car double arrTime double depTime String name car(String, double, double) park ( ) leave( ) balk( ) Methods park, leave, and balk invoked from Lot objects -- messages displayed on monitor
Design Phase – State Transition Diagrams push push start 0 1 lot_size - 1 pop pop push isEmpty ==TRUE error State Transitions of Spar Objects
Design Phase – Refine Object Model push(Car) pop( ) Spar push(Car) Lot Car List attributes pop( ) methods IsEmpty( )
Design Phase – Refine Object Model Class Spar is_a Stack class Spar extends Stack { private static final int sparSize = 4; public void push (Car myCar) { if (size ( ) < sparSize) { super.push(); } }
Object-oriented Analysis and Design Source code for Parking Lot simulation classes Car.javaclass Car, Lot.javaclass Lot Deck.java class Deck, LotSim.java Application class Source code for PriorityQ and EventDriver classes PriorityQ.java A data structure for holding event notices EventDriver.java An application that generates and processes events