CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and...

9
CIS1402 – Introduction to CIS Tom Gustafson * Object-Oriented Basics

Transcript of CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and...

Page 1: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

CIS1402 – Introduction to CIS

Tom Gustafson

*Object-Oriented Basics

Page 2: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What Is an Object?

*An object is an entity that has attributes and methods.

*Ex: A light bulb is an object.

*The attributes of a light bulb could be:

* Florescent or Incandescent

*Watts

* Size

*The methods of a light bulb could be:

* Turn on

* Turn off

* Insert

Page 3: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What Is an Object?

*With computers, there are many objects:

*Files

*User accounts

*Groups

*Hardware components

*Services

Page 4: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What Is an Object?

*A User Account has attributes and methods

*Attributes (Properties or Data)

*Username

*Password

*Creation Date

*Methods (Actions or Operations)

*Disable Account

*Change Password

*Log off

Page 5: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What Is an Object?

*Think of an attribute (property or data) of an object like a place holder to store information about the object. It’s like a variable. It’s like a field in a database record.

*Think of a method (action or operation) as something you do to the object. It’s like a function or procedure. It does something.

Page 6: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What is a Class?

*A “Class” is at type or category of object.

*For example, “light bulb” is a class of object.

*All objects of class light bulb have the same attributes and methods.

*Attributes like watts, size, etc.

*Methods like turn on/off, insert, etc.

*But, two objects of the same class can have different values for their attributes. Ex: one may be 75 watt and another may be 100 watt.

Page 7: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What is a Class?

*Here are some classes of real-life objects:

*Car

*Tree

*Person

*Book

*Every car has VIN, make, and model attributes and start and brake methods.

*An object is an instance of the class it is part of.

Page 8: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*What is a Class?

*On a Computer, there are many classes of objects. Here are three:

*Service

* Attributes: name, status, type

*Methods: start, stop, pause

*File

* Attributes: name, creation date, read-only

*Methods: delete, rename, open

*User Account

* Attributes: name, password, lockout status

*Methods: change password, log off, disable,

Page 9: CIS1402 – Introduction to CIS Tom Gustafson. * An object is an entity that has attributes and methods. * Ex: A light bulb is an object. * The attributes.

*Summary

*There are classes or categories of objects.

*An object is an instance of its class.

*Every class of object has the same:

*Methods – actions that can be performed on an object of that class

*Attributes – properties of every object of that class