Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739

Similar presentations


Presentation on theme: "CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739"— Presentation transcript:

1 CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739 alphonce@buffalo.edu

2 State systems State-based system: –system’s behavior based on its current state Many systems are state-based: –Cable/Satellite TV box –Wrist-watch –Cell phone interface

3

4 State Diagram OFFON push button

5 State Pattern example

6 Polymorphism Behavior determined by method of object, because… it’s the object that responds: –the type of the object determines response –the type of the reference to object doesn’t

7 Polymorphism declared type of variable a supertype of actual type of object

8 Proxy Pattern Polymorphism

9 Polymorphism (in proxy pattern) context delegates method call to concrete tool

10 State Pattern delegation

11 Delegation in State code public class DeskLamp { private IState _state; public DeskLamp() { _state = new Off(); } public void pushButton() { _state.pushButton(this); } public void setState(IState s) { _state = s; }


Download ppt "CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739"

Similar presentations


Ads by Google