Lecture6-Feb1-Interfaces

Lecture6-Feb1-Interf - 1 1 45 COP 3503 SPRING 2012 Shayan Javed Lecture 6 Programming 2 45 Interfaces 3 45 Animal picture food sleep roam makeNoise

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

View Full Document Right Arrow Icon
1 / 45 COP 3503 SPRING 2012 Shayan Javed Lecture 6 Programming 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 / 45 Interfaces
Background image of page 2
3 / 45 Animal picture food sleep() roam() makeNoise() eat()
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 / 45 Animal picture food sleep() roam() makeNoise() eat() Feline roam() Canine roam()
Background image of page 4
5 / 45 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 5

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

View Full DocumentRight Arrow Icon
6 / 45 Problem Need to add Pet behaviors to the pet animal classes (Cat and Dog): play()
Background image of page 6
7 / 45 Option 1 Add concrete methods: play() to Animal class Animal Feline Canine Lion Cat Wolf Dog
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 / 45 Option 1 Add concrete methods: play() to Animal class What’s the problem? Animal Feline Canine Lion Cat Wolf Dog
Background image of page 8
9 / 45 Option 1 Add concrete methods: play() to Animal class What’s the problem? Also exist for Lion/Wolf Animal Feline Canine Lion Cat Wolf Dog
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 / 45 Option 2 Add abstract methods: play() to Animal class Animal Feline Canine Lion Cat Wolf Dog
Background image of page 10
11 / 45 Option 2 Add abstract methods: play() to Animal class Provide empty body for it in Lion and Wolf classes Animal Feline Canine Lion Cat Wolf Dog
Background image of page 11

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

View Full DocumentRight Arrow Icon
12 / 45 Option 2 Add abstract methods: play() to Animal class Provide empty body for it in Lion and Wolf classes Provide non-empty body for it in Cat and Dog classes Animal Feline Canine Lion Cat Wolf Dog
Background image of page 12
13 / 45 Option 3 Add concrete methods: play() to Cat and Dog classes Animal Feline Canine Lion Cat Wolf Dog
Background image of page 13

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

View Full DocumentRight Arrow Icon
14 / 45 What we need Pet behaviors just in Pet classes (like Dog and Cat)
Background image of page 14
15 / 45 What we need Pet behaviors just in Pet classes (like Dog and Cat) Consistency - Guarantee that all Pet classes use the same signature for Pet methods
Background image of page 15

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

View Full DocumentRight Arrow Icon
16 / 45 What we need Pet behaviors just in Pet classes (like Dog and
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/15/2012 for the course COP 3503 taught by Professor Staff during the Spring '12 term at University of Florida.

Page1 / 45

Lecture6-Feb1-Interf - 1 1 45 COP 3503 SPRING 2012 Shayan Javed Lecture 6 Programming 2 45 Interfaces 3 45 Animal picture food sleep roam makeNoise

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

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