Presentation is loading. Please wait.

Presentation is loading. Please wait.

Re-Intro to Object Oriented Programming

Similar presentations


Presentation on theme: "Re-Intro to Object Oriented Programming"— Presentation transcript:

1 Re-Intro to Object Oriented Programming
Prof. Elizabeth Adams

2 What are objects? Objects are classes
For example, we can have a Car object also known as a Car class The Car class has attributes or fields that belong to every existing car For example: Serial number Color Maker Number of doors

3 What do you call a particular object?
an instance of the class Each instance of the class will have all of the attributes of the class

4 What does a class consist of?
State – which is reflected in its attributes Behavior – which is reflected in its actions carried out by its methods

5 How do you create an instance of a class?
You use the new operator

6 Can you have more than one instance of a class?
yes

7 How do you manipulate object instances
By calling or invoking methods aka functions or we can pass messages

8 What do methods consist of?
Header (name and a parameter list which MAY be empty) and a body

9 What are parameters? “stuff” that the methods need to pass additional values into the object instance or content of the messages that are being passed to the object instance

10 What is the signature of a method?
What everyone agrees is part of the signature is the method (function) name, number, type and order of parameters. What others include is the return type. We have been using the 1st definition and calling the 2nd definition the method header

11 Can you re-use (concurrently) method names?
Yes, as long as either the number, type or order of the parameters is different.

12 What kinds of methods are there?
Constructor – creates a new object instance Accessor – return information about the state of an object instance Mutator – changes the state of an object

13 The “condition” of its attributes
What is state? The “condition” of its attributes

14 How can you determine state?
By using its accessor methods

15 When we talk about attributes of a class, what are other names we use?
Instance variables or fields or properties

16 public class Slogan //Listing 6
public class Slogan //Listing 6.3 – page 297 { private String phrase; private static int count = 0; public Slogan (String str) // constructor { phrase = str; count++; } public String toString() // returns a String { return phrase; } public static int getCount () // returns a count of # slogans created { return count; } } Discuss modifiers: static and private Discuss accessor, constructor, mutator

17


Download ppt "Re-Intro to Object Oriented Programming"

Similar presentations


Ads by Google