Object Oriented Analysis and Object Oriented Programming Session

Object Oriented Analysis and Object Oriented Programming Session 5 LBSC 790 / INFM 718 B Building the Human-Computer Interface

Agenda • Collaboration and sequence diagrams • Getting from diagrams to Java code • Making sense of the API • What’s in a GUI?

Flight Finder Exercise http: //www. glue. umd. edu/~oard/spacea/ff/

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

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

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

Collaboration Diagram 3: get. Text() Andrews: Airfield 13: get. Lat. Long() AF 302: Flight 9: get. Text() LAX: Airfield 8: get. Text() 11: get. Text() second: Leg 10: get. Text() Lambert: Airfield Sep 26: Schedule 12: get. Lat. Long() 14: plot(r: Route) 6: get. Text() 5: get. Text() 15: plot(r: Route) () ext : Timeline et. T : GUI 7: g 2: get. Text() : Map NV 514: Flight first: Leg 4: get. Text() 1: Route Scott: Airfield DC: Location C-9 B: Aircraft. Type LA: Location Scenario: First route selected

Sequence Diagram near: Airfields all: Airfields : GUI andrews: Airfield first: Leg find. Near(dept): Airfields return near next. Airfield(): Airfield return andrews next. Leg(): Leg return first get. Destination(): Airfield return scott find. Near(scott): Airfields return near Continue depth-first search, pruning unsuccessful routes after 9 legs

Practice Exercise • Create a Class Diagram for an academic transcript – Include a method to add courses – 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

Working with the Java API • Instantiate an object: – String s = new String(“test”); – int i = s. index. Of(“s”); • Directly use a static method: – int z = Math. min(x, 42); • Use a static method to get an object: – Number. Formatter f = Number. Format. get. Currency. Instance(); – String d = f. format(327);

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.
- Slides: 15