Chapter 4. Introduction to Classes and Objects


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

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

Objectives

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 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



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net