Java_Interfaces_1 - CIS3023: Programming Fundamentals for...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Interfaces (Part I) Course Lecture Slides 9 June 2010 “ As far as the customer is concerned, the interface is the product. ” -- Jef Raskin
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Animal picture food sleep() roam() makeNoise() eat() Feline roam() Canine roam() Lion makeNoise() eat() Cat makeNoise() eat() Wolf makeNoise() eat() Dog makeNoise() eat()
Background image of page 2
Problem Need to add following methods to model Pet behaviors to the pet animal classes play() beFriendly()
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Option 1 Add concrete methods: play() and beFriendly() to Animal class Animal Feline Canine Lion Cat Wolf Dog
Background image of page 4
Option 2 Add abstract methods: play() and beFriendly() to Animal class Provide empty body for them in Lion and Wolf classes Provide non-empty body for them in Cat and Dog Animal Feline Canine Lion Cat Wolf Dog
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Option 3 Add concrete methods: play() and beFriendly() only in Cat and Dog classes Animal Feline Canine Lion Cat Wolf Dog
Background image of page 6
What do we need? Pet behaviors just in Pet classes like Dog and Cat A way to guarantee that all Pet classes use the same signature for these Pet methods A way to take advantage of Polymorphism
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Animal
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/27/2011 for the course CIS 3023 taught by Professor Dobbins during the Summer '08 term at University of Florida.

Page1 / 22

Java_Interfaces_1 - CIS3023: Programming Fundamentals for...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online