Presentation is loading. Please wait.

Presentation is loading. Please wait.

MCS 270 Spring 2014 Object-Oriented Software Development.

Similar presentations


Presentation on theme: "MCS 270 Spring 2014 Object-Oriented Software Development."— Presentation transcript:

1 MCS 270 Spring 2014 Object-Oriented Software Development

2 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Today’s schedule State Diagrams Java Review-Example MCS 270 Object-Oriented Software Development

3 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Class model: describes the static structure of objects and relationships in a system Comprises object and class diagrams State model: describes the dynamic aspects of objects and the nature of control in a system Interaction model: describes how objects in a system cooperate to achieve broader results Unified modeling language (UML) MCS 270 Object-Oriented Software Development

4 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu State Model MCS 270 Object-Oriented Software Development Describes the changes in objects that occur in response to stimuli (events) Consists of multiple state diagrams, one for each class, with temporal behavior that is important to an application

5 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu What is a State Diagram? A state diagram models dynamic behavior. Specifies sequence of states in which an object can exist: The events and conditions that cause the object to reach those states The actions that take place when those states are reached MCS 270 Object-Oriented Software Development Assistant Professor Tenured

6 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu LAMP State Diagram OffOn-lowOn-high Burned-out click MCS 270 Object-Oriented Software Development

7 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu State Model States: An abstraction of the values and links of an object Some states are “special” Events : Internal and external occurrences that impact, or are generated by, an object Transitions : Response of an object based on events and present state On a change of state, the transition is said to fire MCS 270 Object-Oriented Software Development

8 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu State Diagram Notation States: labeled roundtangles Transitions: directed arcs, labeled by triggering event, guard condition, and/or effects Example: ST event(attribs) [condition] / effect States Event Transition MCS 270 Object-Oriented Software Development Guard ConditionEffect

9 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Guard Condition Boolean expression that must be true for transition to occur Checked only once, at time event occurs; transition fires if true MCS 270 Object-Oriented Software Development

10 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Enabling and firing of transitions Transition is: enabled if source state is active and guard condition satisfied fires when enabled and triggering event occurs Example below: enabled when state is Editing and form is complete fires when user presses the “OK” button EditingSubmitted pressOK [form complete] MCS 270 Object-Oriented Software Development

11 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu State Diagram Components start state final state simple state concurrent composite state sequential composite state MCS 270 Object-Oriented Software Development

12 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu “One-shot” state diagrams Represent objects with finite lives have initial and finite states Initial state - entered on object creation Final state - entry implies destruction of object MCS 270 Object-Oriented Software Development

13 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu selecting verifying downloading checking schedule download course offerings make a course selection[download complete] verify selection check schedule select another course make a different selection unscheduled scheduled sign schedule MCS 270 Object-Oriented Software Development

14 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Example White’s turn Black’s turn white moves black moves checkmate stalemate Chess game start state final state MCS 270 Object-Oriented Software Development

15 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Example White’s turn Black’s turn Black wins White wins Draw white moves black moves checkmate stalemate Chess game start state Final states MCS 270 Object-Oriented Software Development

16 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Activity/Effect Activity/Effect = behavior invoked by any number of effects May be performed upon: a transition entry to or exit from a state some event within a state Notation: event / resulting-activity Idle Menu visible r_button_down /showPopup r_button_up/ hidePopup MCS 270 Object-Oriented Software Development

17 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Entry and Exit Activities Opening entry / motor up exit / motor off Can bind activities to entry to/ exit from a state MCS 270 Object-Oriented Software Development

18 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Do-Activities PaperJam do/ flash warning light Continue for an extended time Occur only within a state Performed for all or part of time object is in state May be interrupted by other events MCS 270 Object-Oriented Software Development

19 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Practice: Tic Tac Toe MCS 270 Object-Oriented Software Development

20 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Practice: Phone System MCS 270 Object-Oriented Software Development

21 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Practice Groups of two: A digital watch has a display and 2 buttons: A and B. The watch has two modes of operation: display time and set time. In the display time, the watch shows hours and minutes. Set time has 2 submodes: set hours and set minutes. The A button selects modes. Each time it is pushed, mode advances: display, set hrs, set mins. In a submode, B advances hours or minutes. Create the state diagram. MCS 270 Object-Oriented Software Development

22 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Java Review - Arrays MCS 270 Object-Oriented Software Development Arrays in Java are objects. The first line of code creates a reference for an array object. The second line creates the array object. int [] arrayRef; arrayRef = new int[5]; arrayRef[2] = 5; All arrays have a length property that gives you the number of elements in the array. args.length is determined at runtime

23 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Java Practice MCS 270 Object-Oriented Software Development Use arrays to define the UndirectedGraph class from yesterday. (Assume Vertex and Edge have been defined) class UndirectedGraph { } Use arrays to define the DirectedGraph class from yesterday. class DirectedGraph { }

24 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Assignments Monday - Homework: Chapter 5. Exercise 5.3, 5.4 Due Friday, Feb. 21 MCS 270 Object-Oriented Software Development


Download ppt "MCS 270 Spring 2014 Object-Oriented Software Development."

Similar presentations


Ads by Google