160 likes | 225 Views
Object Oriented Analysis and Object Oriented Programming. Session 5 LBSC 790 / INFM 718B 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.
E N D
Object Oriented AnalysisandObject Oriented Programming Session 5 LBSC 790 / INFM 718B 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/
FlightFinder Use Case Diagram Search <<include>> JOSAC Parse Sched Traveler <<include>> 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 * 1..9 1..* 1 Route Leg Flight Sequence of Sequence of * * * * Displayed in Flies between Contains 1 0..1 2 1 GUI Airfield Schedule 1 1 Travel between Uses Displayed in 1 2 1 Map Location AircraftType Displayed in 1 Timeline
Full Class Diagram * 1..9 1..* 1 Route Leg Flight Sequence of Sequence of * +addLeg(l:Leg) +summary():String -seats: integer -departureTime: Time -arrivalTime:Time +parse(s:String) +summary():String -flightNumber:String +parse(s:String) * * Displayed in * Flies between Contains 0..1 Uses GUI Airfield Schedule 1 1 +search(p:Param) +display(r:Route) -name:String -icaoIdentifier:String{4} -updated:Time -source:URL +parse(f:File) 2 1 1 Travel between 1 Map Location AircraftType Displayed in 2 Displayed in +draw(r:Route) -latitude:double -longitude:double -timeZone:TimeZone +distanceTo(l:Location) -name:String -speed:int +flightTime(o:Location, d:Location) 1 1 Timeline +draw(r:Route)
Object Diagram 1st 1:Route 2nd NV514:Flight :Leg -flightNumber:NV514 -seats=34 -departureTime=1600Z -arrivalTime=1900Z :Leg AF302:Flight Lambert:Airfield :GUI -seats=3 -departureTime=1200Z -arrivalTime:1400Z -flightNumber:AF302 -name=Lambert Field -icaoIdentifier=KSTL O LAX:Airfield Andrews:Airfield -name=LA Intl Airport -icaoIdentifier=KBLV -name=Andrews AFB -icaoIdentifier=KADW Sep26:Schedule D :Map -updated:Sep 26/1200Z -source:http://www… O DC:Location Scott:Airfield D -latitude:38-48N -longitude:076-51W -timeZone=EASTERN -name=Scott AFB -icaoIdentifier=KBLV O C-9B:AircraftType :Timeline -name=C-9B -speed=450 knots LA:Location Key: O = Origin D = Destination -latitude=33-57N -longitude=118-24W -timeZone=PACIFIC D
Collaboration Diagram 3:getText() 1:Route NV514:Flight first:Leg 2:getText() 4:getText() 7:getText() 5:getText() 6:getText() 1:getText() 8:getText() second:Leg AF302:Flight Lambert:Airfield :GUI 10:getText() 11:getText() 9:getText() 14:plot(r:Route) LAX:Airfield Andrews:Airfield Sep26:Schedule :Map 12:getLatLong() Scott:Airfield 15:plot(r:Route) DC:Location C-9B:AircraftType :Timeline 13:getLatLong() LA:Location Scenario: First route selected
Sequence Diagram near:Airfields all:Airfields :GUI andrews:Airfield first:Leg findNear(dept):Airfields return near nextAirfield():Airfield return andrews nextLeg():Leg return first getDestination():Airfield return scott findNear(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.indexOf(“s”); • Directly use a static method: • int z = Math.min(x,42); • Use a static method to get an object: • NumberFormatter f = NumberFormat.getCurrencyInstance(); • String d = f.format(327);
Classes to Explore in the API • String • Manipulate strings (e.g., to extract substrings) • StringTokenizer • Pick apart strings (e.g., into words) • GregorianCalendar • 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 thing that was discussed during today’s class.