CSCI 62 Data Structures Dr. Joshua Stough September 9, 2008.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Chapter 8 Inheritance Part 2. © 2004 Pearson Addison-Wesley. All rights reserved8-2 Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
Inheritance Inheritance Reserved word protected Reserved word super
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Java Inheritance. What is inherited A subclass inherits variables and methods from its superclass and all of its ancestors. The subclass can use these.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
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,
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
CS 106 Introduction to Computer Science I 04 / 21 / 2010 Instructor: Michael Eckmann.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Java Classes Using Java Classes Introduction to UML.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
CSE 501N Fall ‘09 14: Inheritance 20 October 2009 Nick Leidenfrost.
CPSC 102: Computer Science II Dr. Roy P. Pargas 408 Edwards Hall Office Hours 10:00-11:00 am MWF 2:00-3:00 pm TTh.
15440 Distributed Systems Recitation 1 Objected-Oriented Java Programming.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Coming up: Inheritance
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
OO terminology & objectives §Encapsulation l don’t touch my private data l get/set it using my public/package methods §Inheritance l a parent provides.
CSCI 62 Data Structures Dr. Joshua Stough September 11, 2008.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
OOP Basics Classes & Methods (c) IDMS/SQL News
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
Comp1004: Building Better Objects II Encapsulation and Constructors.
Comp1004: Inheritance II Polymorphism. Coming up Inheritance Reminder Overriding methods – Overriding and substitution Dynamic Binding Polymorphism –
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Polymorphism and access control. RHS – SOC 2 What is polymorphism? In general: the ability of some concept to take on different forms In Java: the ability.
OOP: Encapsulation &Abstraction
Interface, Subclass, and Abstract Class Review
Chapter 3: Using Methods, Classes, and Objects
Classes and Objects: Encapsulation
Classes and Objects Encapsulation
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Java Programming Language
Inheritance, Polymorphism, and Interfaces. Oh My
Fall 2018 CISC124 12/3/2018 CISC124 or talk to your grader with questions about assignment grading. Fall 2018 CISC124 - Prof. McLeod Prof. Alan McLeod.
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
Week 4 Object-based Programming (2) Classes and Objects: A Deeper Look
Java Inheritance.
CMPE212 – Reminders Assignment 2 due next Friday.
CMSC 202 Encapsulation Version 9/10.
CSG2H3 Object Oriented Programming
Presentation transcript:

CSCI 62 Data Structures Dr. Joshua Stough September 9, 2008

Today Object-oriented design Interface Assert Generics Program 1.

OO Data Abstraction and Encapsulation –cars, toasters, lightbulbs, Strings... –interface – important to the user –implementation – details hidden from user –A fixed interface allows alternative implementations. Maximize efficiency, minimize errors –Hitchhiker’s Guide

Concerning the development of fire: The girl in charge of fire development said “When you’ve been in marketing as long as I have you’ll know that before any new product can be developed it has to be properly researched. We’ve got to find out what people want from fire, how they relate to it, what sort of image it has for them. “Stick it up your nose,” Ford said. “Which is precisely the sort of thing we need to know. Do people want fire that can be fitted nasally?”

Concerning developing the wheel: “We’re having a little difficulty there.” “Difficulty?” exclaimed Ford. “Difficulty? What do you mean, difficulty? It’s the single simplest machine in the entire Universe!” The marketing girl soured him with a look. “All right, Mr. Wiseguy,” she said, “you’re so clever, you tell us what color it should be.”

OO Object Model –class – defines objects of the class type. –object – instance of a class. –Object – all non-primitive objects extend Object. implements toString, equals –An object manages it own data constructor, accessor and mutator methods comprise the interface. Example: cannot change the key/account in a(n) Association/BankAccount –package – collection of related classes (ideally). We’ve seen –Ratio –BankAccount –TextCoinStrip (soon)

OO public – everyone has access, protected – children (subclasses), via extends, have access, private – only the instance has access. Overloading – same name, different parameter list Overriding – same name/parameter list, child class.

OO – WordList Example No implementation details needed to use the WordList A way to think about it: –Write/think about the pseudocode that uses the object BEFORE implementing the object. –HangMan before WordList –Can be iterative – you start coding in more detail and determine additional functionality.

Interfaces public interface ClassName A class can implement an interface –The class must implement all of the interface’s methods

Assert Firecrackers in the code Defined in the structure5 package (bailey.jar). void pre(boolean test, String message) Can be placed in any method

Generics Recognize errors sooner rather later. generic – class parameterized by the type of data. Java tutorial, generics example. Vector, or Vector Class def.: public class Association Instantiation: Association personAttribute = new Assocation ("Age",34); autoboxed type parameters

Program 1 TextCoinStrip –How did you do it? GraphicsCoinStrip –Make functional Instantiate the strip, place a coin Comment out the void method bodies –Add some functionality mousePressed should carry the coin mouseReleased should put the coin back.