class CashBox; class FrontPanel; class Mixer; class Dispenser; class CoffeeMachine { public: CoffeeMachine(); ~CoffeeMachine(); void insertCoin(int amount); void select(int drink); void returnCoin(); enum Ingredient { SUGAR, CREAM, WATER, COFFEE, CUP, NUM_INGRED}; enum DispAmount {INIT_AMOUNT = 20}; private: CashBox* pCashBox; FrontPanel* pFrontPanel; Mixer* pMixer; }; // CashBox class // Responsibility: // Knows amount of money put in. // Gives change. // Knows price of coffee. // Turns FrontPanel on and off. class CashBox { public: CashBox(FrontPanel* pFP); void insertCoin(int amount); void coinReturnPushed(); void coffeeServed(); bool makeChange(bool ); void ejectCoin(); void ejectAllCoins(); private: FrontPanel* pFrontPanel; }; // class FrontPanel // Responsibilities: // Captures selection. // Knows what to mix in each cup. // Instructs Mixer what to mix. class FrontPanel { public: FrontPanel(Mixer* pM); void enable(); void disable(); void select(int drinkType); void nowOutOf(int ingred); enum Drinks { BLACK, WHITE, BLACK_SUGAR, WHITE_SUGAR, NUM_CHOICES}; private: Mixer* pMixer; CashBox* pCashBox; }; // class Mixer // Responsibilities: // Knows how to talk to dispensers. // Mixer owns Dispensers in this design // (else it is a useless object) class Mixer { public: Mixer(); ~Mixer(); void dispense(int ingred); void nowOutOf(int ingred); void setFrontPanel(FrontPanel* pfp); void addDispenser( int ingred, int init_amount); private: vector<Dispenser*> dispensers; FrontPanel* pFrontPanel; }; // class Dispenser // Responsibilities: // Knows how to dispense a fixed amount. // Knows when it's empty. class Dispenser { public: Dispenser(Mixer* pM, int ingred, int initAmount); void dispense(); private: Mixer* pMixer; }; //End of File