The radio  Has a case  The case separates the controls on the outside (the client interface) from the electronic guts inside (the implementation).

Slides:



Advertisements
Similar presentations
Fields, Constructors, Methods
Advertisements

 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics (inheritance review + Java generics)
Bag implementation Add(T item) – Enlarge bag if necessary; allocate larger array Remove(T item) – Reduce bag if necessary; allocate smaller array Iterator.
Memento Kendra Kachelein Maureen Thomas. Definition The memento captures and externalizes an object’s internal state, so the object can be restored to.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
UML Class Diagram: class Rectangle
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Pattern Abstract Factory
Object Oriented Software Development
Module 7: Essentials of Object-Oriented Programming.
Introduction to Object-oriented programming and software development Lecture 1.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
1 Exercise /* A lockbox can be open or closed. If closed, only a valid password will open the box. Once the box is open, the contents can be retrieved.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
INTRO TO OO Object lessons on Objects. Objects 2  In Java, everything has a type  Primitive types (numbers / booleans / chars)  Complex types (classes)
Starting Out With Java 5 (Control Structures to Objects) Chapter 6 By Tony Gaddis Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
1 Given the Radio class  We may define other derivative types: Cassette walkman IS-A radio Alarm clock radio IS-A radio Car radio IS-A radio.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Designing Classes Prelude © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank.
Creational Pattern: Factory Method At times, a framework is needed to standardize the behavior of objects that are used in a range of applications, while.
C# G 1 CSC 298 Object Oriented Programming Part 2.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Mechanisms for Reuse CMPS OOP billed as technology that permits software to be constructed from general-purpose reusable components Two main mechanisms.
1 The finalize, clone, and getClass Methods  The finalize method is invoked by the garbage collector on an object when the object becomes garbage.  The.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Inheritance Type/Subtype Relationship. Inheritance Idea: An object B of one type, termed child class, inherits from another object A of another type,
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Object-Oriented Programming: Polymorphism Chapter 10.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
ENCAPSULATION. WHY ENCAPSULATE? So far, the objects we have designed have all of their methods and variables visible to any part of the program that has.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
External Scope CECS 277 Mimi Opkins.
Lecture 12 Inheritance.
Object-Orientated Design: Part 2
A first Look at Classes.
Object Oriented Analysis and Design
Teaching Computing to GCSE
Corresponds with Chapter 7
State Design Pattern 1.
Defining Classes and Methods
C++ Polymorphism Reference and pointer implicit type casting
Software Design Lecture : 28.
Inheritance in C++ Inheritance Protected Section
CSG2H3 Object Oriented Programming
Presentation transcript:

The radio  Has a case  The case separates the controls on the outside (the client interface) from the electronic guts inside (the implementation).

The Radio  Most electronic devices warn us not to break encapsulation with stickers that say things like, "This device should be serviced by certified professionals only. If you remove this panel, you will void your warranty."

Objects  An object…. has state (its present condition - stores data). Has behavior (operations defined on it).

this radio object has  fields that define its state Is it on or off? What station is it tuned to? What is the volume setting?

this radio object has  Operations that involve : Observing the present state  Look at settings (accesses information) Changing the present state  Change settings (modifies state of radio)

myVolume myStation myIsOnStatus The Radio class setVolume() setIsOn() setStation() getVolume() getStation() getIsOn()

A class  The description of what comprises an object of a particular type is a class  class Radio would specify that an object (radio) has an on/off indicator, a station indicator, a volume indicator, and an on/off control, a station select control, a volume setting control.  This is a definition of a radio.

this radio  An object of this Radio class It has these controls  We sometimes say: An instance of the Radio class We instantiate Radio….

Instances of the Radio class myVolume myStation myIsOnStatus setVolume() getVolume() other methods here

Given the Radio class  We may define other derivative types: Cassette walkman IS-A radio Alarm clock radio IS-A radio Car radio IS-A radio

What about all of these radios??  ALL HAVE On-off control Volume control Station setting  SOME HAVE MORE

Simple class Hierarchy diagram Radio isOnStatus myVolume myStation boolean getOnOffStatus() void setIsOnStatus() int getVolume() void setVolume() int getStation() void setStation() Walkman What does a walkman have that makes it more than a Radio? AlarmClockRadio alarmSetting alarmStatus someTimeType getAlamTime() void setAlarmTime() boolean getAlarmStatus() setAlarmStatus() CarRadio What does a car radio have that makes it more than a Radio?

And we can get as complicated as we want…  What about our HomeEntertainment Center?

HomeEntertainmentCenter  HAS-A Radio  HAS-A Cassette Player  HAS-A CDPlayer  HAS-A DVDPlayer  HAS-A Television

Maybe each of these 'pieces' is  A subclass of an EntertainmentElectronicDevice class????

Using other objects…  Some objects can be useful for building larger systems.  A Radio may be a part of a home entertainment system that involves several other components.  A Radio can be a subclass of some ElectronicEntertainment Device class.  We still do not need to know the implementation details about the radio, only the interface for connecting it to other components.