[Cs3] Lab 11 Decorator Question

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Apr 14 13:52:52 EDT 2016


> 
> I have my classes for Decorator setup as:
> Coffee
> 
> Size: Coffee
> 
> AddIngrediants: Coffee
> 
> Do you recommend me putting the coffee size part in the base class Coffee, and creating subclasses for each decoration (caramel, ice, etc...)?
> Coffee {
> <size input from user>
> };
> 
> Caramel: Coffee
> 
> Ice: Coffee
> 

This sounds reasonable: have a base class: Coffee (with size as an
attribute) and ingredients as separate concrete decorators. Note that
you also need to implement coffee price calculation.

Thanks,
-- 
Mikhail


More information about the cs3 mailing list