Chapter 3 - Chapter3 GettingStarted Objects

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
    Chapter 3 Getting Started
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Objects Every Java program is composed of  objects. Think of an object as a discreet piece or  building block. (Like LEGOs only better) Each building block has its own set of  properties  and  behaviors,  which influence how  it interacts with other objects.
Background image of page 2
    Properties A property of an object is something that helps  describe it. Examples: Size Color A reference (pointer) to another object An ID number
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Behaviors A behavior is something the object is capable of  doing. Examples: Add two numbers Change its color Draw itself on the screen Alphabetize a set of words
Background image of page 4
    Interaction Properties and behaviors tend to interact with  one another. For example, if you tell an object to draw itself,  it will probably check to see what the value of  its “color” property is first.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    Classes class  is a description (like a blueprint) of an  object. class   is not   an object! A class is the plan  used to build an object. When you write a class, you are defining a  ‘class’ of objects. ..
Background image of page 6
    Classes The class defines what properties and behaviors a  given object will have when it is created. If the class says: “Any objects built from this plan will  have a property called ‘height’”, then all such objects  will have that property. If the class says: “Any objects built from this plan will  be able to play songs by CCR” (a behavior), then all  such objects will be able to.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
    (Little Side Note) The Animator is a Java program that you modify to display objects graphically. ..
Background image of page 8
  Writing a Class Definition Here is the code for a simple class definition : public class Sun extends Animator { public void draw(Graphics g) {
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/28/2011 for the course CS 1131 taught by Professor Staff during the Fall '08 term at Michigan Technological University.

Page1 / 24

Chapter 3 - Chapter3 GettingStarted Objects

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online