Title: Object Oriented Analysis and Object Oriented Programming
1Object Oriented AnalysisandObject Oriented
Programming
- Session 5
- LBSC 790 / INFM 718B
- Building the Human-Computer Interface
2Agenda
- Collaboration and sequence diagrams
- Getting from diagrams to Java code
- Making sense of the API
- Whats in a GUI?
3Flight Finder Exercise
http//www.glue.umd.edu/oard/spacea/ff/
4FlightFinder Use Case Diagram
Search
ltltincludegtgt
JOSAC
Parse Sched
Traveler
ltltincludegtgt
Select
5Search 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
6Select 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
maptimelinetext - Termination
- Display completed
- Post-conditions
- Details displayed
7Simple Class Diagram
1..9
1
1..
Route
Leg
Flight
Sequence of
Sequence of
Flies between
Contains
Displayed in
1
2
0..1
1
GUI
Airfield
Schedule
1
1
Travel between
Uses
Displayed in
1
1
2
Map
Location
AircraftType
Displayed in
1
Timeline
8Full Class Diagram
1..9
1
1..
Route
Leg
Flight
Sequence of
Sequence of
addLeg(lLeg) summary()String
-seats integer -departureTime
Time -arrivalTimeTime parse(sString) summary()
String
-flightNumberString parse(sString)
Displayed in
Flies between
Contains
0..1
Uses
GUI
Airfield
Schedule
1
1
search(pParam) display(rRoute)
-nameString -icaoIdentifierString4
-updatedTime -sourceURL parse(fFile)
2
1
1
Travel between
1
Map
Location
AircraftType
Displayed in
2
Displayed in
draw(rRoute)
-latitudedouble -longitudedouble -timeZoneTimeZ
one distanceTo(lLocation)
-nameString -speedint flightTime(oLocation,
dLocation)
1
1
Timeline
draw(rRoute)
9Object Diagram
1st
1Route
2nd
NV514Flight
Leg
-flightNumberNV514
-seats34 -departureTime1600Z -arrivalTime1900Z
Leg
AF302Flight
LambertAirfield
GUI
-seats3 -departureTime1200Z -arrivalTime1400Z
-flightNumberAF302
-nameLambert Field -icaoIdentifierKSTL
O
AndrewsAirfield
LAXAirfield
Sep26Schedule
-nameAndrews AFB -icaoIdentifierKADW
-nameLA Intl Airport -icaoIdentifierKBLV
D
Map
-updatedSep 26/1200Z -sourcehttp//www
O
DCLocation
ScottAirfield
D
-latitude38-48N -longitude076-51W -timeZoneEAST
ERN
-nameScott AFB -icaoIdentifierKBLV
O
C-9BAircraftType
Timeline
-nameC-9B -speed450 knots
LALocation
Key O Origin D Destination
-latitude33-57N -longitude118-24W -timeZonePACI
FIC
D
10Collaboration Diagram
3getText()
1Route
NV514Flight
firstLeg
2getText()
7getText()
4getText()
1getText()
5getText()
6getText()
8getText()
secondLeg
AF302Flight
LambertAirfield
GUI
10getText()
11getText()
9getText()
14plot(rRoute)
AndrewsAirfield
LAXAirfield
Sep26Schedule
Map
12getLatLong()
ScottAirfield
15plot(rRoute)
DCLocation
C-9BAircraftType
Timeline
13getLatLong()
LALocation
Scenario First route selected
11Sequence Diagram
GUI
allAirfields
nearAirfields
andrewsAirfield
firstLeg
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
12Practice 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
13Working 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.getCurrencyInstan
ce() - String d f.format(327)
14Classes 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
15Muddiest 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 todays class.