Interfaces - COP 3330 Slides 3/24 Topics Interfaces Enums A...

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

View Full Document Right Arrow Icon
Slides 3/24 COP 3330
Background image of page 1

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

View Full DocumentRight Arrow Icon
Topics Interfaces Enums
Background image of page 2
A Good Design … is Modular This is a key aspect of object-oriented design A modular system is composed of interchangeable parts In order for a modular design to be effective, the ways in which the different components can interact must be well defined
Background image of page 3

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

View Full DocumentRight Arrow Icon
Interfaces Interfaces specify methods that must be implemented in classes that implement the interface Example: The Comparable interface requires that a compareTo method be implemented Example: The Iterable interface requires that the iterator method be implemented
Background image of page 4
Interfaces A particular class can implement an unbounded number of interfaces (provided that they don’t conflict) Indicate that your class implements an interface by using the implements keyword
Background image of page 5

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

View Full DocumentRight Arrow Icon
Interfaces Example: public class MyClass implements Comparable, Iterable<MyClass> { public int compareTo(Object x){ } public Iterator<MyClass> iterator(){ } }
Background image of page 6
Interfaces You can define your own interfaces
Background image of page 7

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

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

Page1 / 17

Interfaces - COP 3330 Slides 3/24 Topics Interfaces Enums A...

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

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