The Coffee Control System is a S/W program attached to Coffee
Equipment to control coffee item information. The Coffee Control
System responds to the following commands initiated by a user
or supervisor to fill and dispense items (coffee, cups, sugar,
and cream): Fill Cup, Fill Coffee, Fill Sugar, Fill Cream, Dispense
Cup, Dispense Coffee, Dispense Sugar, Dispense Cream, Get Current
Cups, Get Current Coffees, Get Current Sugars, Get Current Creams.
The Coffee Control System responds to these commands by returning
information and by issuing the following responses to the Coffee
Equipment: Show Status, Dispense Cup, Dispense Coffee, Dispense
Sugar, Dispense Cream.
The following information (data) is passed between the equipment
and the Coffee Control System: number of cups, number of coffees,
number of sugars, and number of creams.
| System Name | Attribute Names | System Operation Names |
| CoffeeEquipment | showStatus dispenseCup dispenseCoffee dispenseSugar dispenseCream | |
| CoffeeControlSystem | numberCups numberCoffees numberSugars numberCreams | fillCup fillCoffee fillSugar fillCream dispenseCup dispenseCoffee dispenseSugar dispenseCream getCurrentCups getCurrentCoffees getCurrentSugars getCurrentCreams |
System Name: Coffee Control System
System Access: Public
System Imports: NA
Enclosing System: NA
System Description: The Coffee Control System controls
the dispensing of cups, coffees, sugars, and creams.
| Entity Name | Type of Entity | Enclosing System |
| CoffeeEquipment | System | -- |
| dispenseCup | System Operation | CoffeeEquipment |
| dispenseCoffee | System Operation | CoffeeEquipment |
| dispenseSugar | System Operation | CoffeeEquipment |
| dispenseCream | System Operation | CoffeeEquipment |
| showStatus | System Operation | CoffeeEquipment |
| CoffeeControlSystem | System | -- |
| numberCups | Attribute | CoffeeControlSystem |
| numberCoffees | Attribute | CoffeeControlSystem |
| numberSugars | Attribute | CoffeeControlSystem |
| numberCreams | Attribute | CoffeeControlSystem |
| fillCup | System Operation | CoffeeControlSystem |
| fillCoffee | System Operation | CoffeeControlSystem |
| fillSugar | System Operation | CoffeeControlSystem |
| fillCream | System Operation | CoffeeControlSystem |
| dispenseCup | System Operation | CoffeeControlSystem |
| dispenseCoffee | System Operation | CoffeeControlSystem |
| dispenseSugar | System Operation | CoffeeControlSystem |
| dispenseCream | System Operation | CoffeeControlSystem |
| getCurrentCups | System Operation | CoffeeControlSystem |
| getCurrentCoffees | System Operation | CoffeeControlSystem |
| getCurrentSugars | System Operation | CoffeeControlSystem |
| getCurrentCreams | System Operation | CoffeeControlSystem |
System Use Cases/Sub-use Cases Table
| Number | Initiating Actor | Use Case
/Sub-use Case |
Description |
| 1 | Maintainer | Fill Coffee Items | Coffee Control System sets the number to 500 and initiates a showStatus event. Maintainer may initiate a getCurrentCoffee, getCurrentCups, getCurrentSuggars, or getCurrentCreams |
| 1.1 | Maintainer | Fill Cup | Coffee Control System sets the cup number to 500 and initiates a showStatus event. Maintainer may initiate getCurrentCups. |
| 1.2 | Maintainer | Fill Coffee | Coffee Control System sets the coffee number to 500 and initiates a showStatus event. Maintainer may initiate getCurrentCoffee |
| 1.4 | Maintainer | Fill Sugar | Coffee Control System sets the sugar number to 500 and initiates a showStatus event. Maintainer may initiate getCurrentSugarsms |
| 1.4 | Maintainer | Fill Cream | Coffee Control System sets the cream number to 500 and initiates a showStatus event. Maintainer may initiate getCurrentCreams |
| 2 | User | Dispense Coffee Items | Coffee Control System issues a dispense output event. |
| 2.1 | User | Dispense Cup | Coffee Control System issues a dispenseCup output event. |
| 2.2 | User | Dispense Coffee | Coffee Control System issues a dispenseCoffee output event. |
| 2.3 | User | Dispense Sugar | Coffee Control System issues a dispenseSugar output event. |
| 2.4 | User | Dispense Cream | Coffee Control System issues a dispenseCream output event. |
Use Case Table - Fill Coffee Items Use Case
| Sequence # | Sender System | Receiver System | Invoked Operation | Description |
| 1 | Coffee Equipment | Coffee Control System | fillCup | Input Event |
| 2 | Coffee Control System | Coffee Equipment | showStatus | Output Event |
| 3 | Coffee Equipment | Coffee Control System | fillCoffee | Input Event |
| 4 | Coffee Control System | Coffee Equipment | showStatus | Output Event |
| 5 | Coffee Equipment | Coffee Control System | fillSugar | Input Event |
| 6 | Coffee Control System | Coffee Equipment | showStatus | Output Event |
| 7 | Coffee Equipment | Coffee Control System | fillCream | Input Event |
| 8 | Coffee Control System | Coffee Equipment | showStatus | Output Event |
Use Case Table - Dispense Coffee Items Use Case
| Sequence # | Sender System | Receiver System | Invoked Operation | Description |
| 1 | Coffee Equipment | Coffee Control System | dispenseCup | Input Event |
| 2 | Coffee Control System | Coffee Equipment | dispenseCup | Output Event |
| 3 | Coffee Equipment | Coffee Control System | dispenseCoffee | Input Event |
| 4 | Coffee Control System | Coffee Equipment | dispenseCoffee | Output Event |
| 5 | Coffee Equipment | Coffee Control System | dispenseSugar | Input Event |
| 6 | Coffee Control System | Coffee Equipment | dispenseSugar | Output Event |
| 7 | Coffee Equipment | Coffee Control System | dispenseCream | Input Event |
| 8 | Coffee Control System | Coffee Equipment | dispenseCream | Output Event |
Creams (return aNumber) Returns number of creams
| System Operation Name | Input Parameters | Transformation | Return Type |
| dispenseCup | numberCups = numberCups - 1 | void | |
| dispenseCoffee | numberCoffees = numberCoffees - 1 | void | |
| dispenseSugar | numberSugars = numberSugars - 1 | void | |
| dispenseCream | numberCreams = numberCreams - 1 | void | |
| fillCup | numberCups = 500 | void | |
| fillCoffee | numberCoffees = 500 | void | |
| fillSugar | numberSugars = 500 | void | |
| fillCream | numberCreams = 500 | void | |
| getCurrentCups | void | ||
| getCurrentCoffees | void | ||
| getCurrentSugars | void | ||
| getCurrentCreams | void |
Note: correctness assertions must be added to ensure a positive
number of items exists before a dispense operation is executed.
| Class Name | Attribute Names | Relationship Traversal Path Names | Operation Names |
| Item | number | getNumber setNumber fill getCurrentItems dispense | |
| Cup | dispense | ||
| Coffee | dispense | ||
| Sugar | dispense | ||
| Cream | dispense | ||
| CoffeeController | theCup theCoffee theSugar theCream | fill dispense getCurrentItems | |
| UserInterface | theCoffeeController | fillCup fillCoffee fillSugar fillCream dispenseCup dispenseCoffee dispenseSugar dispenseCream getCurrentCups getCurrentCoffees getCurrentSugars getCurrentCreams |
Data Dictionary for Object Model - Coffee Control System
| Entity Name | Type of Entity | Enclosing Class |
| number | Attribute | Item |
| Item | Class | -- |
| Cup | Class | -- |
| Coffee | Class | -- |
| Sugar | Class | -- |
| Cream | Class | -- |
| CoffeeController | Class | -- |
| UserInterface | Class | -- |
| getNumber | Operation | Item |
| setNumber | Operation | Item |
| fill | Operation | Item |
| getCurrentItems | Operation | Item |
| dispense | Operation | Item |
| dispense | Operation | Cup |
| dispense | Operation | Coffee |
| dispense | Operation | Sugar |
| dispense | Operation | Cream |
| fill | Operation | CoffeeController |
| dispense | Operation | CoffeeController |
| getCurrentItems | Operation | CoffeeController |
| fillCup | Operation | UserInterface |
| fillCoffee | Operation | UserInterface |
| fillSugar | Operation | UserInterface |
| fillCream | Operation | UserInterface |
| dispenseCup | Operation | UserInterface |
| dispenseCoffee | Operation | UserInterface |
| dispenseSugar | Operation | UserInterface |
| dispenseCream | Operation | UserInterface |
| getCurrentCups | Operation | UserInterface |
| getCurrentCoffees | Operation | UserInterface |
| getCurrentSugars | Operation | UserInterface |
| getCurrentCreams | Operation | UserInterface |
| theCup | Traversal Path for 1:1 Aggregation | CoffeeController |
| theCoffee | Traversal Path for 1:1 Aggregation | CoffeeController |
| theSugar | Traversal Path for 1:1 Aggregation | CoffeeController |
| theCream | Traversal Path for 1:1 Aggregation | CoffeeController |
| theCoffeeController | Traversal Path for 1:1 Aggregation | UserInterface |
| Sequence # | Sender System/Object | Receiver System/Object | Invoked Operation | Description |
| 1 | Coffee Equipment | theUserInterface | fillCup | Input Event |
| 2 | theUserInterface | theCoffeeController | fillCup | Message |
| 3 | theCoffeeController | theCup | fill | Message |
| 4 | theUserInterface | Coffee Equipment | showStatus | Output Event |
| 5 | Coffee Equipment | theUserInterface | fillCoffee | Input Event |
| 6 | theUserInterface | theCoffeeController | fillCoffee | Message |
| 7 | theCoffeeController | theCoffee | fill | Message |
| 8 | theUserInterface | Coffee Equipment | showStatus | Output Event |
| 9 | Coffee Equipment | theUserInterface | fillSugar | Input Event |
| 10 | theUserInterface | theCoffeeController | fillSugar | Message |
| 11 | theCoffeeController | theSugar | fill | Message |
| 12 | theUserInterface | Coffee Equipment | showStatus | Output Event |
| 13 | Coffee Equipment | theUserInterface | fillCream | Input Event |
| 14 | theUserInterface | theCoffeeController | fillCream | Message |
| 15 | theCoffeeController | theCream | fill | Message |
| 16 | theUserInterface | Coffee Equipment | showStatus | Output Event |
| Sequence # | Sender System/Object | Receiver System/Object | Invoked Operation | Description |
| 1 | Coffee Equipment | theUserInterface | dispenseCup | Input Event |
| 2 | theUserInterface | theCoffeeController | dispenseCup | Message |
| 3 | theCoffeeController | theCup | dispense | Message |
| 4 | theUserInterface | Coffee Equipment | dispenseCup | Output Event |
| 5 | Coffee Equipment | theUserInterface | dispenseCoffee | Input Event |
| 6 | theUserInterface | theCoffeeController | dispenseCoffee | Message |
| 7 | theCoffeeController | theCoffee | dispense | Message |
| 8 | theUserInterface | Coffee Equipment | dispenseCoffee | Output Event |
| 9 | Coffee Equipment | theUserInterface | dispenseSugar | Input Event |
| 10 | theUserInterface | theCoffeeController | dispenseSugar | Message |
| 11 | theCoffeeController | theSugar | dispense | Message |
| 12 | theUserInterface | Coffee Equipment | dispenseSugar | Output Event |
| 13 | Coffee Equipment | theUserInterface | dispenseCream | Input Event |
| 14 | theUserInterface | theCoffeeController | dispenseCream | Message |
| 15 | theCoffeeController | theCream | dispense | Message |
| 16 | theUserInterface | Coffee Equipment | dispenseCream | Output Event |
| Class Name | Operation Name | Input Parameters | Transformation | Return Type |
| Item | getNumber | int | ||
| Item | setNumber | int aNumber | number = aNumber | void |
| Item | fill | number = 500 | void | |
| Item | getCurrentItems | int | ||
| Item | dispense | void | ||
| Cup | dispense | number = number - 1 | void | |
| Coffee | dispense | number = number - 1 | void | |
| Sugar | dispense | number = number - 1 | void | |
| Cream | dispense | number = number - 1 | void | |
| CoffeeController | fill | Item* theItem | void | |
| CoffeeController | dispense | Item* theItem | void | |
| CoffeeController | getCurrentItems | Item* theItem | int | |
| UserInterface | fillCup | void | ||
| UserInterface | fillCoffee | void | ||
| UserInterface | fillSugar | void | ||
| UserInterface | fillCream | void | ||
| UserInterface | dispenseCup | void | ||
| UserInterface | dispenseCoffee | void | ||
| UserInterface | dispenseSugar | void | ||
| UserInterface | dispenseCream | void | ||
| UserInterface | getCurrentCups | int | ||
| UserInterface | getCurrentCoffees | int | ||
| UserInterface | getCurrentSugars | int | ||
| UserInterface | getCurrentCreams | int |
Note: correctness assertions must be added to ensure a positive
number of items exists before a dispense operation is executed.
////////Coffee Control System Prototype////////////////////////
#include <iostream.h>
////////////////////////////////////////////////////////////////
class Item // Base Class
{ // Abstract Class with
private: // at least one pure virtual
int number; // function. Cannot declare
protected: // an an object of an abstract class
int getNumber () {return number;}; // Accessor Function
void setNumber (int aNumber) {number = aNumber;};
//Accessor Function public:
Item ();
void fill ();
int getCurrentItems (){return getNumber();}
virtual void dispense () = 0; //Pure Virtual Function = 0
}; //Put definition in derived classes
Item::Item () {setNumber (0);} //Constructor
void Item::fill () {setNumber (500);}
///////////////////////////////////////////////////////////////
class Cup : public Item // Derived Class
{
public:
Cup ();
void dispense ();
};
Cup::Cup () : Item () {}
//add cup specialized code
void Cup :: dispense () {int aNumber = getNumber() - 1; setNumber (aNumber);
cout << "\nOne cup dispensed - number remaining is " << getNumber();
}
///////////////////////////////////////////////////////////////
class Coffee : public Item // Derived Class
{
public:
Coffee ();
void dispense ();
};
Coffee::Coffee () : Item () {}
//add coffee specialized code
void Coffee :: dispense (){int aNumber = getNumber() - 1; setNumber (aNumber);
cout << "\nOne coffee dispensed - number remaining is " << getNumber();
}
///////////////////////////////////////////////////////////////
class Sugar : public Item // Derived Class
{
public:
Sugar ();
void dispense ();
};
Sugar::Sugar () : Item () {}
//add sugar specialized code
void Sugar :: dispense () {int aNumber = getNumber() - 1; setNumber (aNumber);
cout << "\nOne sugar dispensed - number remaining is " << getNumber();
}
///////////////////////////////////////////////////////////////
class Cream : public Item // Derived Class
{
public:
Cream ();
void dispense ();
};
Cream::Cream () : Item () {}
//add specialized code
void Cream::dispense () {int aNumber = getNumber() - 1; setNumber (aNumber);
cout << "\nOne cream dispensed - number remaining is " << getNumber();
}
//////////////////////////////////////////////////////////////
class CoffeeController // Class
{ public:
Cup theCup;
Coffee theCoffee;
Sugar theSugar;
Cream theCream;
CoffeeController ();
void fill (Item *theItem);
void dispense (Item *theItem);
int getCurrentItems (Item *theItem);
};
CoffeeController::CoffeeController(){}
void CoffeeController::fill (Item *theItem)
{ theItem->fill(); }
void CoffeeController::dispense (Item *theItem)
{ theItem->dispense(); }
int CoffeeController::getCurrentItems (Item *theItem)
{int aNumber = theItem -> getCurrentItems (); return aNumber; }
//////////////////////////////////////////////////////////////
class UserInterface
{ CoffeeController theCoffeeController;
public:
void fillCup () {theCoffeeController.fill (&theCoffeeController.theCup);
cout << "Cups filled.\n"; }
void fillCoffee () {theCoffeeController.fill (&theCoffeeController.theCoffee);
cout << "Coffee filled.\n";
}
void fillSugar () {theCoffeeController.fill (&theCoffeeController.theSugar);
cout << "Sugar filled.\n";
}
void fillCream () {theCoffeeController.fill (&theCoffeeController.theCream);
cout << "Cream filled.\n";
}
void dispenseCup () {theCoffeeController.dispense (&theCoffeeController.theCup);
cout << "Cup dispensed.\n";
}
void dispenseCoffee () {theCoffeeController.dispense (&theCoffeeController.theCoffee);
cout << "Coffee dispensed.\n";
}
void dispenseSugar () {theCoffeeController.dispense (&theCoffeeController.theSugar);
cout << "Sugar dispensed.\n";
}
void dispenseCream () {theCoffeeController.dispense (&theCoffeeController.theCream);
cout << "Cream dispensed.\n";
}
void getCurrentCups () {
cout << "The current number of cups is ";
cout << theCoffeeController.getCurrentItems (&theCoffeeController.theCup);
cout << ".\n";
}
void getCurrentCoffees () {
cout << "The current number of coffees is ";
cout << theCoffeeController.getCurrentItems (&theCoffeeController.theCoffee);
cout << ".\n";
}
void getCurrentSugars () {
cout << "The current number of sugars is ";
cout << theCoffeeController.getCurrentItems (&theCoffeeController.theSugar);
cout << ".\n";
}
void getCurrentCreams () {
cout << "The current number of creams is ";
cout << theCoffeeController.getCurrentItems (&theCoffeeController.theCream);
cout << ".\n";
}
};
main ()
{ UserInterface theUserInterface;
theUserInterface.fillCup ();
theUserInterface.fillCoffee ();
theUserInterface.fillSugar ();
theUserInterface.fillCream ();
theUserInterface.dispenseCup ();
theUserInterface.getCurrentCups ();
theUserInterface.dispenseCoffee ();
theUserInterface.getCurrentCoffees ();
theUserInterface.dispenseSugar ();
theUserInterface.getCurrentSugars ();
theUserInterface.dispenseCream ();
theUserInterface.getCurrentCreams ();
return (0);
}
/* ------------------ Output --------------------------------
Cups filled.
Coffee filled.
Sugar filled.
Cream filled.
One cup dispensed - number remaining is 499.
One coffee dispensed - number remaining is 499.
One sugar dispensed - number remaining is 499.
One cream dispensed - number remaining is 499.
The current number of cups is 499.
The current number of coffees is 499.
The current number of sugars is 499.
The current number of creams is 499.
*/