Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-oriented Programming and Collaboration and Sequence Diagrams Session 5 LBSC 790 / INFM 718B Building the Human-Computer Interface.

Similar presentations


Presentation on theme: "Object-oriented Programming and Collaboration and Sequence Diagrams Session 5 LBSC 790 / INFM 718B Building the Human-Computer Interface."— Presentation transcript:

1 Object-oriented Programming and Collaboration and Sequence Diagrams Session 5 LBSC 790 / INFM 718B Building the Human-Computer Interface

2 Agenda Object-Oriented Programming –Exercise questions –Working with the Java API Javadoc documentation Packages –Subclasses & object creation (maybe) Collaboration and Sequence Diagrams Idea Rally, part 2

3 Classes to Explore in the API String –Manipulate strings (e.g., to extract substrings) NumberFormatter –So you can print pretty numbers Math –Useful math functions GregorianCalendar –Dates and times

4 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);

5 Java Classes Java classes represent types of things –Can be thought of as blueprints for objects Classes = state + actions –State is represented by variables –Actions are represented by methods Scope rules support abstract thinking –Public: can be used from other classes –Private: can only be seen in the class

6 Subclasses & Inheritance Location Airfield -airportCode:String{3} +getAirportCode() +getDistanceTo(a:Airfield) -latitude:double -longitude:double -timeZone:TimeZone -name:String +distanceTo(l:Location) +getName() (is-a)

7 Object creation The stack –Local variables The heap –Instance variables Constructors

8

9 Exercise 3, part 4 Library +search(...) Book -title:String -author:Str’g -copyrightYear: integer -available:integer +checkIn() +checkOut() +equals(b:Book) Size -width:double -height:double +equals(s: Size) 3..30..* owns 1 * has

10 Bill’s Budget Flight Finder

11 Flies between * 0..1 1 1 FlightFinder Class Diagram (2) Route GUI Map Timeline Location Airfield Leg AircraftType Schedule Flight 1 * 1..911..** Sequence of 2 1 Travel between +addLeg(l:Leg) +summary():String +search(p:Param) +display(r:Route) +draw(r:Route) -seats: integer -departureTime: Time -arrivalTime:Time +parse(s:String) +summary():String -name:String -icaoIdentifier:String{4} -latitude:double -longitude:double -timeZone:TimeZone +distanceTo(l:Location) -flightNumber:String +parse(s:String) -updated:Time -source:URL +parse(f:File) -name:String -speed:int +flightTime(o:Location, d:Location) Contains Uses Displayed in 1 1 Displayed in 1 * 2 *

12 D FlightFinder Object Diagram 1:Route :GUI :Map :Timeline DC:Location Andrews:Airfield :Leg C-9B:AircraftType Sep26:Schedule AF302:Flight -seats=3 -departureTime=1200Z -arrivalTime:1400Z -name=Andrews AFB -icaoIdentifier=KADW -latitude:38-48N -longitude:076-51W -timeZone=EASTERN -flightNumber:AF302 -updated:Sep 26/1200Z -source:http://www… -name=C-9B -speed=450 knots LA:Location -latitude=33-57N -longitude=118-24W -timeZone=PACIFIC Scott:Airfield -name=Scott AFB -icaoIdentifier=KBLV Lambert:Airfield :Leg -seats=34 -departureTime=1600Z -arrivalTime=1900Z -name=Lambert Field -icaoIdentifier=KSTL LAX:Airfield -name=LA Intl Airport -icaoIdentifier=KBLV NV514:Flight -flightNumber:NV514 O D O O D 1st 2nd Key: O = Origin D = Destination

13 Modeling the system Capturing the big picture Designing the object structure –Class diagram (“entity-relationship” diagram) –Object diagram (used to show examples) Represent object interactions for a scenario Represent event-object interactions

14 Collaboration Diagram 1:Route :GUI :Map :Timeline DC:Location Andrews:Airfield second:Leg C-9B:AircraftType Sep26:Schedule AF302:Flight LA:Location Scott:Airfield Lambert:Airfield first:Leg LAX:Airfield NV514:Flight 1:getText() 7:getText() 2:getText() 5:getText()6:getText() 3:getText() 4:getText() 10:getText()11:getText() 8:getText() 9:getText() 13:getLatLong() 12:getLatLong() 15:plot(r:Route) 14:plot(r:Route) Scenario: First route selected

15 Sequence Diagram :GUIall:Airfieldsnear:Airfieldsandrews:Airfieldfirst:Leg findNear(dept):Airfields return near nextAirfield():Airfield return andrews nextLeg():Leg return first getDestination():Airfield return scott return near findNear(scott):Airfields Continue depth-first search, pruning unsuccessful routes after 9 legs

16

17 Idea Rally – part 2 Pitches rigidly timed (90 seconds) Focus on the points that you believe will most impress your classmates Discussion afterwards –Exchange / refine ideas –Start forming teams

18 Coming up Homework 2 –Will post by Friday evening –Graded During the coming week –Form teams; email 2 sentence description to me –Use the lab Next week: –More on object-oriented programming Read: HFJ 10 & 11 –Maybe preview: Graphical user interfaces –Project check-in

19 Stop / Start / Continue Please write one thing that you would like us to… –Stop doing * –Start doing –Continue doing …in class * Note: homework will not stop…

20

21 Show and Tell What cool resources have you found? –Books and Web sites? What new Java tricks have you learned? What do you need to know to make progress?


Download ppt "Object-oriented Programming and Collaboration and Sequence Diagrams Session 5 LBSC 790 / INFM 718B Building the Human-Computer Interface."

Similar presentations


Ads by Google