Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object-Oriented Programming

Similar presentations


Presentation on theme: "Object-Oriented Programming"— Presentation transcript:

1 Object-Oriented Programming
color size getColor drift draw x, y

2 What is a Balloon?

3 What is a Balloon? It Depends...

4 What is a Balloon? It Depends...
Is it for a game app? Is it for bookstore inventory app?

5 What is a Balloon? It Depends...
Is it for a game app? If so, a balloon has: color size position on screen

6 What is a Balloon? It Depends...
Is it for a game app? If so, a balloon has: color size position on screen Is it for bookstore inventory app? If so, a balloon has: price manufacturer shelf number

7 Description of a Balloon:
done public class Balloon { }

8 Description of a Balloon:
(1) balloon’s features are: color size position on screen done public class Balloon { }

9 Description of a Balloon:
(1) balloon’s features are: color size position on screen done public class Balloon { // data members String color; double size; double x, y; }

10 Description of a Balloon:
(1) balloon’s features are: color size position on screen (3) balloon’s behaviors are: report its features drift draw itself done public class Balloon { // data members String color; double size; double x, y; }

11 Description of a Balloon:
(1) balloon’s features are: color size position on screen (3) balloon’s behaviors are: report its features drift draw itself done public class Balloon { // data members String color; double size; double x, y; // methods String getColor() void drift( double dx, ... ) void draw() }

12 Description of a Balloon:
(1) balloon’s features are: color size position on screen (2) balloon’s can be created: by giving values for features (3) balloon’s behaviors are: report its features drift draw itself done public class Balloon { // data members String color; double size; double x, y; // methods String getColor() void drift( double dx, ... ) void draw() }

13 Description of a Balloon:
(1) balloon’s features are: color size position on screen (2) balloon’s can be created: by giving values for features (3) balloon’s behaviors are: report its features drift draw itself done public class Balloon { // data members String color; double size; double x, y; // constructor(s) Balloon( String c, ..., ...) // methods String getColor() void drift( double dx, ... ) void draw() }

14 public class Balloon { // data members private String color; private double size; private double x, y; // constructor(s) public Balloon( String c, ..., ...) // methods public String getColor() public void drift( double dx, ... ) public void draw() }

15 public Balloon( String c, ..., ...) // methods
public class Balloon { // data members private String color; private double size; private double x, y; // constructor(s) public Balloon( String c, ..., ...) // methods public String getColor() public void drift( double dx, ... ) public void draw() } private means hidden public means available

16 You – Designer of balloon
public class Balloon { // data members private String color; private double size; private double x, y; // constructor(s) public Balloon( String c, ..., ...) // methods public String getColor() public void drift( double dx, ... ) public void draw() } You – Designer of balloon know everything about the balloon

17 Balloon balloon = new Balloon( ... );
public class ParkApp { Balloon balloon = new Balloon( ... ); } .getColor() .drift() .draw() You – User of balloon (in other class) know only public details about balloon


Download ppt "Object-Oriented Programming"

Similar presentations


Ads by Google