Nothing can have value without being an object of utility. Karl Marx
Nothing can have value without being an object of utility.
Karl Marx
You will see something new. Two things. And I call them Thing One and Thing Two. Dr. Theodor Seuss Geisel
You will see something new. Two things. And I call them Thing One and Thing Two.
Dr. Theodor Seuss Geisel
Your public servants serve you right. Adlai E. Stevenson
Your public servants serve you right.
Adlai E. Stevenson
Knowing how to answer one who speaks, To reply to one who sends a message. Amenemope
Knowing how to answer one who speaks, To reply to one who sends a message.
Amenemope
In this chapter you will learn:
What classes, objects, methods, instance variables and properties are.
How to declare a class and use it to create an object.
How to implement a class's behaviors as methods.
How to implement a class's attributes as instance variables and properties.
How to call an object's methods to make them perform their tasks.
The differences between instance variables of a class and local variables of a method.
How to use a constructor to ensure that an object's attributes are initialized when the object is created.
The differences between value types and reference types.
How to use properties to ensure that only valid data is placed in attributes.
Outline
4.1 Introduction4.2 Classes, Objects, Methods and Instance Variables4.3 Declaring a Class with a Method and Instantiating an Object of a Class4.4 Declaring a Method with a Parameter4.5 Instance Variables and Properties4.6 Value Types and Reference Types4.7 Initializing Objects with Constructors4.8 Validating Data with Set Accessors in Properties4.9 (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Document4.10 Wrap-Up
4.1 Introduction
4.2 Classes, Objects, Methods and Instance Variables
4.3 Declaring a Class with a Method and Instantiating an Object of a Class
4.4 Declaring a Method with a Parameter
4.5 Instance Variables and Properties
4.6 Value Types and Reference Types
4.7 Initializing Objects with Constructors
4.8 Validating Data with Set Accessors in Properties
4.9 (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Document
4.10 Wrap-Up