/**
* Copyright (C) 2022 by Martin Robillard. See https://codesample.info/about.html
*/
package e2.chapter3;
/**
* Represents an entity from which it is possible to obtain cards.
*/
public CardSource {
/**
* Returns a card from the source.
*
* @return The next available card.
* @pre !isEmpty()
*/
Card draw();
/**
* @return True if there is no card in the source.
*/
boolean isEmpty();
}
The ability to have different shapes.
The ability to have different shapes.
As mentioned in the Card
example, methods in interfaces are implicitly public
,
even if the keyword public
is omitted.
As mentioned in the Card
example, methods in interfaces are implicitly public
,
even if the keyword public
is omitted.
As mentioned in the Card
example, methods in interfaces are implicitly public
,
even if the keyword public
is omitted.
As mentioned in the Card
example, methods in interfaces are implicitly public
,
even if the keyword public
is omitted.
The goal of an interface is to specify what services (that is, methods) objects of a certain class should have, without committing to a given implementation of these services. Programming with interfaces allows , because different classes can provide different variations of the required behavior.
Chapter 3, insight #1
Use interface types to decouple a specification from its implementation if you plan to have different implementations of that specification as part of your design
The goal of an interface is to specify what services (that is, methods) objects of a certain class should have, without committing to a given implementation of these services. Programming with interfaces allows , because different classes can provide different variations of the required behavior.
Chapter 3, insight #1
Use interface types to decouple a specification from its implementation if you plan to have different implementations of that specification as part of your design