Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch. 2 Discussion Head First Java. Big Idea Differene between a class and an object What benefit object-oriented programming gives you. Read “Chair Wars”

Similar presentations


Presentation on theme: "Ch. 2 Discussion Head First Java. Big Idea Differene between a class and an object What benefit object-oriented programming gives you. Read “Chair Wars”"— Presentation transcript:

1 Ch. 2 Discussion Head First Java

2 Big Idea Differene between a class and an object What benefit object-oriented programming gives you. Read “Chair Wars” – Larry v. Brad – procedural v. object-oriented Application to put a shape on a screen. Differences between procedural programming v. classes – reusable code.

3 Object Oriented A “Class” for each shape P. 29 – a specification change Larry has to put changes into many lines of code Brad creates a new “class” P. 30 – another new specification – Brad has less work than Larry as he modifies the Amoeba class.

4 Chair Wars - continued P. 31 – – Rotate method in all of Brad’s shapes – Duplicate Code Final Design – Inheritance – advanced concept – Power behind it all Brad looked at what all four have in common – He pulled out all of the common features and put them into a generic class – shape. – All four shapes “inherit” from the Shape class.

5 Chair Wars Shape is a “superclass” All four shapes are related and “inherit” the characteristics of the superclass. Square, circle, triangle, amoeba – subclass. Page 32 – Amoeba class can over-ride the methods from Shape. Any changes to Shape impact all the subclasses. The use of “classes” is essential to OOP


Download ppt "Ch. 2 Discussion Head First Java. Big Idea Differene between a class and an object What benefit object-oriented programming gives you. Read “Chair Wars”"

Similar presentations


Ads by Google