DOC PREVIEW
Purdue ECE 462 - Object-Oriented Programming

This preview shows page 1-2-3-4-5-6-7-8-9-10-11-12-83-84-85-86-87-88-89-90-91-92-93-94-167-168-169-170-171-172-173-174-175-176-177-178 out of 178 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 178 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Object and ClassObjects' Three PropertiesWhat is a Class?EncapsulationInheritance and PolymorphismInterface ≠ ImplementationOverridingFundamental Concepts in OOPJava and Qt DocumentationsDevelopment EnvironmentInstall Eclipse at Your Own ComputerDevelop C++ Projects in EclipseDevelop Java Projects in EclipseVersion ControlDevelop Java Projects in NetbeansCompile / Execute C++ Programs in Linux ShellCompile / Execute Java Programs in Linux ShellYHL Object and Class 1ECE 462Object-Oriented Programmingusing C++ and JavaObject and ClassYung-Hsiang [email protected] Object and Class 2What is an Object?An object can be a “concrete and tangible” entity that can be separated with unique properties:–you– your book– your car– my computer–Tom– Amy’s computer– your phone– Sam’s digital camera– Jennifer’s cat ...YHL Object and Class 3What is an object?• An object can be abstract and does not have to be tangible:– Purdue ECE's student database – the email sent by Mark at 9:07AM on 2008/03/22– the web page of Purdue ECE 462– the song played in WBAA at 7:02PM last night• An object can contain other objects:– a car = wheels + engine + door + windshield + ...– a house = kitchen + bedrooms + living room + ...– a laptop = keyboard + display + processor + ...YHL Object and Class 4Objects' Three Properties• Each object is unique and can be identified using name, serial number, relationship with another object ...• Each object has a set of attributes, such as location, speed, size, address, phone number, on/off ...• Each object has unique behaviors, such as ring (phone), accelerate and move (car), take picture (camera), send email (computer), display caller (pager)• Each object has three important properties:– unique identity– attributes, noun– behavior (action), verbYHL Object and Class 5Objects’ Interactions• You (object) press (action) the pedal (object) of your car (object). As a result, your car accelerate (action).• When your phone (object) rings (action) and alerts (action) you (object) of an incoming call (state), you answer (action) the call (state).• You submit (action) homework (object) and it is graded (action) with a score (state).YHL Object and Class 6Object as a Special Case• A person is an object. A student is also an object. A student is a special case of a person ⇒ A student has all attributes of a person:name, home address, parents ...⇒ A student has all behavior of a person:eat, sleep, talk ...⇒ A student has something that a person may not have:– attributes: student ID, list of courses, classmates ...– behavior: submit homework, take exam ...YHL Object and Class 7What is a Class?• A class describes the commonalities of similar objects:– Person: you, David, Mary, Tom, Amy ...– Car: your Toyota Camry, his Ford Explorer, Jennifer's Mercedes C300 ...– Classroom: EE170, EE117, EE129 ...– Building: EE, MSEE, Purdue Bell Tower, Hovde Hall...• A class describes both the attributes and the behavior:– Person: name, home ... + sleep, eat, speak ...– Car: engine size, year ... + accelerate, brake, turn ...YHL Object and Class 8Relationship among Classes• A class can be a special case of another class:– Student is a special case of Person– Sedan is a special case of Car– Laptop is a special case of Computer– Computer is a special case of ElectronicMachine⇒ This is called a "is a" relationship.– any Student object is a Person object– any Sedan object is a Car object– any Laptop object is a Computer object– any Computer object is an ElectronicMachine objectYHL Object and Class 9Class and Object• An object is an instantiation (i.e. concrete example) of a class: – an object is unique– a class describes the common properties of many objects• An object may contain an object. This must be described in the former object's class. We can say that one class "has a" class.YHL Object and Class 10Encapsulation• An object can hide information (attributes) from being manipulated by or even visible to other objects:A person's name is given once when the object is created. This attribute is visible but cannot be changed.• An attribute may be modified by only restricted channels to keep consistency.A person's address and phone number must be change together when this person moves.YHL Object and Class 11Self TestYHL Inheritance and Polymorphism 1ECE 462Object-Oriented Programmingusing C++ and JavaInheritance and PolymorphismYung-Hsiang [email protected] Inheritance and Polymorphism 2Inheritance = "Is A"• Any Student object is a Person object. Student class is a derived class of Person. Person is the base class.⇒ Person is more general, with fewer attributes and behaviors.⇒ Student is more specific, with more attributes (school, major) and behaviors (submit homework, take exam).• Any TabletPC object is a Computer object. TabletPCclass is a derived class of Computer.⇒ Computer is more general.⇒ TabletPC is more specific, with more attributes (battery lifetime) and behavior (close or turn the screen)YHL Inheritance and Polymorphism 3Derived Class• A class may have multiple derived classes:– Car: Sedan, Truck, Sport Utility Vehicle, Sport Car ...– Computer: Laptop, Desktop, Server – Person: Student, Teacher, Father, Mother ...• A derived class may also have derived classes:– Vehicle: Car, Bike ... Car: Sedan, Truck ...– Animal: Bird, Mammal ... Mammal: Dog, Cat ...• Use "base" and "derived" classes. Do not use "super" and "sub" classes. A base class or a superclass is "smaller" (fewer attributes and behaviors) ⇒ too confusingYHL Inheritance and Polymorphism 4Why Object-Oriented?• Object-oriented programming (OOP) is more natural to describe the interactions between "things" (i.e. objects).• OOP provides better code reuse:– commonalities among objects described by a class– commonalities among classes described by a base class (inheritance)• Objects know what to do using their attributes:Each object responds differently to "What is your name?" • OOP provides encapsulation: hide data that do not have to be visible to the other objects or protect data from unintentional, inconsistent changes.YHL Inheritance and Polymorphism 5Interface ≠ ImplementationIf a behavior is common among classes, the behavior should be available in their base class. However, this behavior may need additional information from derived classes and must be handled in


View Full Document

Purdue ECE 462 - Object-Oriented Programming

Download Object-Oriented Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Object-Oriented Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Object-Oriented Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?