Object Oriented Analysis and Object Oriented Programming Session
Object Oriented Analysis and Object Oriented Programming Session 4 LBSC 790 / INFM 718 B Building the Human-Computer Interface
Agenda • Class diagrams • Object design • Object oriented programming in Java
Object Modeling • Models are abstractions of reality – That are created for a specific purpose • Classes represent types of entities – That are important for the chosen purpose – Specify subordinate objects and methods • Objects are specific instances of classes – Encapsulate specific objects and methods
Flight Finder Exercise http: //www. glue. umd. edu/~oard/spacea/ff/
Flight Finder Background • The traveler (or a system administrator) will first obtain schedule data from JOSAC using their Web browser and store it on their hard drive in the received format. Upon program initiation, the Parse Sched use case will run automatically. Once that completes, the traveler may specify the origin, destination, radius around each, and a connection radius (or leave any of the default values set), earliest and latest times, and then initiate the search. Once the search completes, the traveler may step through the interesting routes one at a time, viewing information on which their decision might be based. Once one or more acceptable routes have been identified, the traveler can then contact the appropriate facilities directly to make travel arrangements.
Flight. Finder Use Case Diagram JOSAC Parse Sched e>> d u l nc <<i << inc Search Traveler lud e> > Select
Search Use Case Narrative • Assumptions – Current JOSAC schedule parsed • Pre-conditions – None • Initiation – Search function selected • Dialog – Search parameters selected, search initiated, unknown locations resolved, route list displayed • Termination – Route search complete (normal), unknown location (error) • Post-conditions – Route list displayed (if available) or blank
Select Use Case Narrative • Assumptions – Route list displayed • Pre-conditions – At least one available route • Initiation – Route selected from list • Dialog – Select route, display details in map+timeline+text • Termination – Display completed • Post-conditions – Details displayed
Flight Finder Background • The traveler (or a system administrator) will first obtain schedule data from JOSAC using their Web browser and store it on their hard drive in the received format. Upon program initiation, the Parse Sched use case will run automatically. Once that completes, the traveler may specify the origin, destination, radius around each, and a connection radius (or leave any of the default values set), earliest and latest times, and then initiate the search. Once the search completes, the traveler may step through the interesting routes one at a time, viewing information on which their decision might be based. Once one or more acceptable routes have been identified, the traveler can then contact the appropriate facilities directly to make travel arrangements.
Flight. Finder Class Diagram Route * * 1. . 9 Sequence of * Displayed in 0. . 1 1 GUI Displayed in 1 Map Displayed in 1 Timeline 1 Sequence of Flies between 2 1 1 1. . * Leg Airfield Travel between 2 Flight * * Contains 1 Schedule Uses Location Aircraft. Type 1
Full Flight. Finder Class Diagram Displayed in +add. Leg(l: Leg) +summary(): String GUI Displayed in +search(p: Param) +display(r: Route) 0. . 1 Airfield 1 -name: String -icao. Identifier: String{4} 1 Map +draw(r: Route) 1 Timeline +draw(r: Route) 1 Displayed in 1 -seats: integer -departure. Time: Time -arrival. Time: Time +parse(s: String) +summary(): String Travel between 2 1. . * * 2 1 Sequence of * 1 Flight -flight. Number: String * +parse(s: String) Uses * Leg Contains * 1. . 9 Sequence of Flies between Route Schedule -updated: Time -source: URL +parse(f: File) Location -latitude: double -longitude: double -time. Zone: Time. Zone +distance. To(l: Location) Aircraft. Type -name: String -speed: int +flight. Time(o: Location, d: Location) 1
Flight. Finder Object Diagram 1 st 1: Route 2 nd NV 514: Flight : Leg -flight. Number: NV 514 -seats=34 -departure. Time=1600 Z -arrival. Time=1900 Z : GUI Lambert: Airfield : Leg AF 302: Flight -name=Lambert Field -icao. Identifier=KSTL -seats=3 -departure. Time=1200 Z -arrival. Time: 1400 Z -flight. Number: AF 302 O LAX: Airfield -name=LA Intl Airport -icao. Identifier=KBLV : Map Andrews: Airfield D -name=Andrews AFB -icao. Identifier=KADW Sep 26: Schedule O O : Timeline DC: Location Scott: Airfield -latitude: 38 -48 N -longitude: 076 -51 W -time. Zone=EASTERN -name=Scott AFB -icao. Identifier=KBLV D D C-9 B: Aircraft. Type -name=C-9 B -speed=450 knots LA: Location -latitude=33 -57 N -longitude=118 -24 W -time. Zone=PACIFIC -updated: Sep 26/1200 Z -source: http: //www… Key: O = Origin D = Destination
Class Critique • Multiple instances must be possible – Each uniquely identifiable • • Can’t be subdivided into distinct classes Multiple attributes needed to describe No empty attribute values Methods needed – At least for creation and modification
Attribute Critique • Naturally describes the object – Does not describe some other object • • • Value will be known for some instances Value will never be empty Cannot be subdivided into smaller attributes One value, not a list of values Cannot be computed from other attributes
Relationships • Object relationships – Has-a – Aggregation – Composition • Class relationships – Generalization (“extends”) – “Implements”
Practice Exercise • Create a Class Diagram for an academic transcript – Include a method to compute grade point average – Include a method to print the transcript • Code (only) the transcript class in java – Include a main method that tests the class – Create stubs for any other needed classes • Run your main method
Classes to Explore in the API • String – Manipulate strings (e. g. , to extract substrings) • String. Tokenizer – Pick apart strings (e. g. , into words) • Gregorian. Calendar – Dates and times • Hashtable – Like arrays, but with any object as the index
Muddiest Point On a blank sheet of paper, write a single sentence that will convey to me what you found to be the most confusing that was discussed during today’s class.
Flight. Finder Class Diagram Location Options Airfield keyboard routes name icao. Identifier location compute() display() Route Leg legs flight departure. Field departure. Time arrival. Field arrival. Time available. Seats display() latitude longitude distance. To() time. Zone() Flight flight. Number aircraft legs display() Schedule webpage read. Flight() read. Date() display() Aircraft type display()
- Slides: 19