Using
SingletonPattern.cpp
as a starting point, create a class that manages a fixed number of its own
objects.
Create
a minimal Observer-Observable design in two classes, without base classes and
without the extra arguments in
Observer.h
and the member functions in
Observable.h.
Just create the bare minimum in the two classes, then demonstrate your design
by creating one
Observable
and many
Observers,
and cause the
Observable
to update the
Observers.
Change
InnerClassIdiom.cpp
so that
Outer
uses multiple inheritance instead of the inner class idiom.
Add
a class
Plastic
to TrashVisitor.cpp.
Add
a class
Plastic
to DynaTrash.cpp.
Explain
how
AbstractFactory.cpp
demonstrates
Double
Dispatching
and the
Factory
Method
.
Create
a business-modeling environment with three types of
Inhabitant:
Dwarf
(for engineers),
Elf
(for marketers) and
Troll
(for managers). Now create a class called
Project
that creates the different inhabitants and causes them to
interact(
)
with each other using multiple dispatching.
Modify
the above example to make the interactions more detailed. Each
Inhabitant
can randomly produce a
Weapon
using
getWeapon(
)
:
a
Dwarf
uses
Jargon
or
Play,
an
Elf
uses
InventFeature
or
SellImaginaryProduct,
and a
Troll
uses
Edict
and
Schedule.
You must decide which weapons “win” and “lose” in each
interaction (as in
PaperScissorsRock.cpp).
Add a
battle(
)
member function to
Project
that takes two
Inhabitants
and matches them against each other. Now create a
meeting(
)
member function for
Project
that creates groups of
Dwarf,
Elf
and
Manager
and battles the groups against each other until only members of one group are
left standing. These are the “winners.”