Object-Oriented Programming color size getColor drift draw x, y
What is a Balloon?
What is a Balloon? It Depends...
What is a Balloon? It Depends... Is it for a game app? Is it for bookstore inventory app?
What is a Balloon? It Depends... Is it for a game app? If so, a balloon has: color size position on screen
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
Description of a Balloon: done public class Balloon { }
Description of a Balloon: (1) balloon’s features are: color size position on screen done public class Balloon { }
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; }
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; }
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() }
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() }
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() }
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() }
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
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
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