QuackObservable Interface Hierarchy:
QuackObservable
: Interface for objects that can be observed.
Observable
: Concrete implementation managing observers and notifying them.
DuckCall
: This represents a duck call that can quack.GooseAdapter
: Adapt a goose to behave like a duck.MallardDuck
: Represents a mallard duck.RedheadDuck
: Represents a redhead duck.RubberDuck
: Represents a rubber duck.QuackCounter
: Decorator that counts quacks of another Quackable
.Observer Interface Hierarchy:
Observer
: Interface for objects that observe QuackObservable
subjects.
Quackologist
: A concrete observer that prints quack information.Quackable Interface Hierarchy:
Quackable
: Interface for objects that can quack.
QuackCounter
: Decorator that counts quacks and delegates to another Quackable
.DuckCall
: This represents a duck call that can quack.GooseAdapter
: Adapt a goose to behave like a duck.MallardDuck
: Represents a mallard duck.RedheadDuck
: Represents a redhead duck.RubberDuck
: Represents a rubber duck.Flock
: A composite of multiple Quackable
objects.Duck Factory Hierarchy:
AbstractDuckFactory
: Interface for creating families of related objects.
DuckFactory
: A concrete factory that creates ducks without any decoration.CountingDuckFactory
: A concrete factory that creates ducks and wraps them with QuackCounter
.Duck Simulator Classes:
DuckSimulator
: The main class for simulating ducks.
Quackologist
: An observer that prints quack information.Flock Hierarchy:
Flock
: A composite of multiple Quackable
objects, representing a group of ducks.Goose Classes:
Goose
: Represents a goose that can honk.GooseAdapter
: Adapt a goose to behave like a duck.Observer
, QuackObservable
, Quackologist
, Observable
Quackologist
observes QuackObservable
instances (ducks) to be notified when they quack.Quackable
, QuackCounter
Quackable
ducks. QuackCounter
wraps around another Quackable
and adds counting functionality.Quackable
, Flock
Flock
class is a composite of multiple Quackable
objects, allowing them to be treated as a single unit.AbstractDuckFactory
, DuckFactory
, CountingDuckFactory
AbstractDuckFactory
defines the interface for creating ducks, and DuckFactory
and CountingDuckFactory
are concrete implementations that create different types of ducks.GooseAdapter
Goose
object compatible with the Quackable
interface. GooseAdapter
adapts the Goose
class to behave like a duck.QuackObservable
subjects.QuackObservable
changes.QuackCounter
decorator. Also used by the Flock
composite.Observable:
QuackObservable
to handle the registration and notification of observers.DuckCall:
Goose:
GooseAdapter:
Goose
to behave like a duck (Quackable
).Quackable
object.MallardDuck:
RedheadDuck:
RubberDuck: