Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie.

Similar presentations


Presentation on theme: "Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie."— Presentation transcript:

1 copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie cutter to create items a blueprint to build an item An Object a specific item that has unique properties (characteristics) also called an instance of a class objects are instantiated from classes objects have state and behavior Examples All cars have a color, MPG, and location My car is gray an in parking lot C All people have a height, weight and name Joe is 5’-10 and weights 150 lbs Wonder Woman is a super hero Lassie is a dog Atlas Shrugged is a book

2 copyright by Scott GrissomCh 1 Objects and Classes Slide 2 BlueJ Demo #1 open the Shapes project instantiate an object invoke a method provide parameters inspect an object’s state

3 copyright by Scott GrissomCh 1 Objects and Classes Slide 3 Methods Methods tell an object to do something “raise your hand” “stand up” start engine Some methods require parameters “step forward” - how many steps? “clap hands” - how many times? turn - which direction? Some methods return an answer “what is your name?” what is the square root of 16? return an answer how much gas is in the tank?

4 copyright by Scott GrissomCh 1 Objects and Classes Slide 4 Dog what are characteristics? breed hair color name weight gender what is some appropriate behavior? roll over play dead sit fetch speak

5 copyright by Scott GrissomCh 1 Objects and Classes Slide 5 Car what are characteristics make model color year engine what is a typical behavior start engine brake accelerate turn

6 copyright by Scott GrissomCh 1 Objects and Classes Slide 6 Important Concepts Data types int String boolean State - current values of all attributes Source code - text description of a class including its data fields and methods class is equivalent to a chapter methods are equivalent to paragraphs source code must compile without syntax errors Summary objects are instantiated from classes objects have state and behavior objects have methods that are invoked

7 copyright by Scott GrissomCh 1 Objects and Classes Slide 7 BlueJ Demo #2 open Lab-classes project create a student(s) invoke getName( ) create a LabClass enroll a student

8 copyright by Scott GrissomCh 1 Objects and Classes Slide 8 BlueJ Demo #3 open Picture project build a sunset method build a sunrise method


Download ppt "Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie."

Similar presentations


Ads by Google