The Currency Control System is a S/W program that interacts with currency control equipment to store and exchange various international currencies. The Currency Control System responds to the following commands:
- Set Available Currency Funds, e.g. DM funds = 1000,
- Get Available Currency Funds, e.g. DM funds = 1000,
- Set a Currency Exchange Rate, e.g. US -> DM = 1.50,
- Get a Currency Exchange Rate, e.g. US -> DM = 1.50.
- Exchange a Currency, e.g. 10 US -> 15DM.
The Currency Control System responds to these commands with the following responses:
- Display Status, e.g. DM funds = 1000,
- Dispense an Amount of a Currency, e.g. DM = 15.
The following information (data) is passed between the HW Equipment and the Currency Control System:
- an in currency type, e.g. US, DM, FR,
- an in currency amount, e.g. 100,
- an out currency type, e.g. US, DM, FR,
- an out currency amount, e.g. 150,
- a currency exchange rate, e.g. 1.5.
A currency exchange rate is a float that is used to convert an
amount of an input currency to compute the amount of an output
currency, e.g. the currency exchange rate of a US dollar to a
Deutschemark is 1.5. A in currency amount or out currency amount
is an integer. It is an input amount that a user inputs and an
output amount that a user receives during an exchange. An in currency
type or out curreny type is an available international currency,
e.g. US, DM, and FR.
| System Name | Attribute Names | System Operation Names |
| CurrencyControlSystem | availCurrency currencyRates inCurrencyType outCurrencyType inCurrencyAmount outCurrencyAmount | getAvailCurrency setAvailCurrency getCurrencyRate setCurrencyRate exchangeCurrency |
| HWEquipment | dispenseCurrency displayStatus |
System Name: Currency Control System
System Access: Public
System Imports: NA
Enclosing System: NA
System Description: The Currency Control System controls
the exchange of currencies.
| Entity Name | Type of Entity | Enclosing System |
| CurrencyControlSystem | System | -- |
| availCurrency | Attribute | CurrencyControlSystem |
| currencyRates | Attribute | CurrencyControlSystem |
| inCurrencyType | Attribute | CurrencyControlSystem |
| outCurrencyType | Attribute | CurrencyControlSystem |
| inCurrencyAmount | Attribute | CurrencyControlSystem |
| outCurrencyAmount | Attribute | CurrencyControlSystem |
| getAvailCurrency | System Operation | CurrencyControlSystem |
| setAvailCurrency | System Operation | CurrencyControlSystem |
| getCurrencyRate | System Operation | CurrencyControlSystem |
| setCurrencyRate | System Operation | CurrencyControlSystem |
| exchangeCurrency | System Operation | CurrencyControlSystem |
| HWEquipment | System | -- |
| dispenseCurrency | System Operation | HWEquipment |
| displayStatus | System Operation | HWEquipment |
System Use Cases/Sub-use Cases Table
| Number | Initiating Actor | Use Case/Subuse Case | Use Case Description |
| 1 | Maintainer | Maintain Currency System | General use case with sub-use cases |
| 1.1 | Maintainer | Set Available Currency | Input Event - setAvailableCurrency, Output Event - displayStatus |
| 1.2 | Maintainer | Get Available Currency | Input Event - getAvailableCurrency, Output Event - displayStatus |
| 1.3 | Maintainer | Set Currency Rate | Input Event - setAvailableCurrency, Output Event - displayStatus |
| 2 | User | Use Currency System | General use with sub-use cases |
| 2.1 | User | Get Currency Rate | Input Event - getCurrencyRate, Output Event - displayStatus |
| 2.2 | User | Exchange Currency | Input Event - exchangeCurrency, Output Event - dispenseCurrency |
Use Case Table - Maintain Currency System Use Case
| Sequence Number | Sender System | Receiver System | Invoked Operation | Description |
| 1 | HW Equipment | Currency Control System | setAvailableCurrency | Input Event |
| 2 | Currency Control System | HW Equipment | displayStatus | Output Event |
| 3 | HW Equipment | Currency Control System | getAvailableCurrency | Input Event |
| 4 | Currency Control System | HW Equipment | displayStatus | Output Event |
| 5 | HW Equipment | Currency Control System | setCurrencyRate | Input Event |
| 6 | Currency Control System | HW Equipment | displayStatus | Output Event |
Use Case Table - Use Currency System Use Case
| Sequence Number | Sender System | Receiver System | Invoked Operation | Description |
| 1 | HW Equipment | Currency Control System | getCurrencyRate | Input Event |
| 2 | Currency Control System | HW Equipment | displayStatus | Output Event |
| 3 | HW Equipment | Currency Control System | exchangeCurrency | Input Event |
| 4 | Currency Control System | HW Equipment | displayStatus | Output Event |
| 5 | Currency Control System | HW Equipment | dispenseCurrency | Output Event |
Creams () Returns number of creams
The basic transformation is the exchangeCurrency system operation
that computes an Out Currency Amount based upon an In Currency
Amount, In Currency Type, and Out Currency Type. The basic transformation
is:
Out Currency Amount = In Currency Amount * currencyRates [In Currency
Type]
Correctness assertions must be identified to ensure that correct
outAmount's are computed.
| System Operation Name | Input Parameters | Transformation | Return Type |
| getAvailCurrency | OutCurrencyType | int | |
| setAvailCurrency | OutCurrencyType OutCurrencyAmount | Update outCurrencyAmount | void |
| getCurrencyRate | OutCurrencyType InCurrencyType | float | |
| setCurrencyRate | OutCurrencyType InCurrencyType CurrencyRate | Update currencyRates | |
| exchangeCurrency | InCurrencyType InCurrencyAmount OutCurrencyType | outCurrencyAmount = currencyRates [inCurrencyType] * inCurrencyAmount | int |
| Class Name | Attribute Names | Relationship Traversal Path Names | Operation Names |
| Currency | availCurrency currencyRates | setAvailCurrency getAvailCurrency getCurrencyRate setCurrencyRate exchangeCurrency | |
| USCurrency | exchangeCurrency | ||
| DMCurrency | exchangeCurrency | ||
| CurrencyController | aDM aUS | setAvailCurrency getCurrencyRate setCurrencyRate exchangeCurrency getAvailCurrency | |
| HWInterface | aCurrencyController | dispenseCurrency setAvailCurrency getCurrencyRate setCurrencyRate exchangeCurrency getAvailCurrency |
Data Dictionary for Object Model - Currency Control System
| Entity Name | Type of Entity | Enclosing Class |
| Currency | Class | -- |
| availCurrency | Attribute | Currency |
| currencyRates | Attribute | Currency |
| setAvailCurrency | Operation | Currency |
| getAvailCurrency | Operation | Currency |
| getCurrencyRate | Operation | Currency |
| setCurrencyRate | Operation | Currency |
| exchangeCurrency | Operation | Currency |
| USCurrency | Class | -- |
| exchangeCurrency | Operation | USCurrency |
| DMCurrency | Class | -- |
| exchangeCurrency | Operation | DMCurrency |
| CurrencyController | Class | -- |
| setAvailCurrency | Operation | CurrencyController |
| getCurrencyRate | Operation | CurrencyController |
| setCurrencyRate | Operation | CurrencyController |
| exchangeCurrency | Operation | CurrencyController |
| getAvailCurrency | Operation | CurrencyController |
| aDM | Traversal Path for 1:1 Aggregation | CurrencyController |
| aUS | Traversal Path for 1:1 Aggregation | CurrencyController |
| HWInterface | Class | -- |
| dispenseCurrency | Operation | HWInterface |
| setAvailCurrency | Operation | HWInterface |
| getCurrencyRate | Operation | HWInterface |
| setCurrencyRate | Operation | HWInterface |
| exchangeCurrency | Operation | HWInterface |
| getAvailCurrency | Operation | HWInterface |
| aCurrencyController | Traversal Path for 1:1 Aggregation | HWInterface |
| Sequence # | Sender System/Object | Receiver System
/Object | Invoked Operation | Description |
| 1 | HWEquipment | aHWInterface | getAvailableCurrency | Input Event |
| 2 | aHWInterface | aCurrencyController | getAvailableCurrency | Message |
| 3 | aCurrencyController | aCurrency | getAvailableCurrency | Message |
| 4 | aHWInterface | HWInterface | displayStatus | Output Event |
| 5 | HWEquipment | aHWInterface | setAvailableCurrency | Input Event |
| 6 | aHWInterface | aCurrencyController | setAvailableCurrency | Message |
| 7 | aCurrencyController | aCurrency | setAvailableCurrency | Message |
| 8 | aHWInterface | HWInterface | displayStatus | Output Event |
| 9 | HWEquipment | aHWInterface | setCurrencyRate | Input Event |
| 10 | aHWInterface | aCurrencyController | setCurrencyRate | Message |
| 11 | aCurrencyController | aCurrency | setCurrencyRate | Message |
| 12 | aHWInterface | HWInterface | displayStatus | Output Event |
| Sequence # | Sender System/Object | Receiver System
/Object | Invoked Operation | Description |
| 1 | HWEquipment | aHWInterface | getCurrencyRate | Input Event |
| 2 | aHWInterface | aCurrencyController | getCurrencyRate | Message |
| 3 | aCurrencyController | aCurrency | getCurrencyRate | Message |
| 4 | aHWInterface | HWInterface | displayStatus | Output Event |
| 5 | HWEquipment | aHWInterface | exchangeCurrency | Input Event |
| 6 | aHWInterface | aCurrencyController | exchangeCurrency | Message |
| 7 | aCurrencyController | aCurrency | exchangeCurrency | Message |
| 8 | aHWInterface | HWInterface | displayStatus | Output Event |
| 9 | aHWInterface | HWInterface | dispenseCurrency | Output Event |
The basic transformation is the exchangeCurrency operation
void int exchangeCurrency (Currency anInCurr, int anInCurrAmt)
transformation: int anOutAmount = anInCurrAmt * currencyRates
[anInCurr]
Correctness assertions must be identified to ensure that correct
outAmount's are computed.
| Class Name | Operation Name | Input Parameters | Transformation | Return Type |
| Currency | setAvailCurrency | int amount | availCurrency = amount | void |
| Currency | getAvailCurrency | int | ||
| Currency | getCurrencyRate | Currencies anInCurr | float | |
| Currency | setCurrencyRate | Currencies anInCurr
float aRate | currencyRates [anInCurr] = aRate | void |
| Currency | exchangeCurrency | Currencies anInCurr
int anInCurrAmt | int | |
| USCurrency | exchangeCurrency | Currencies anInCurr int anInCurrAmt |
int anOutAmount = anInCurrAmt * currencyRates [anInCurr] | int |
| DMCurrency | exchangeCurrency | Currencies anInCurr
int anInCurrAmt | int anOutAmount = anInCurrAmt * currencyRates [anInCurr] | int |
| CurrencyController | setAvailCurrency | Currency* aCurrency
int amount |
void | |
| CurrencyController | getCurrencyRate | Currency* aCurrency Currencies anInCurr | float | |
| CurrencyController | setCurrencyRate | Currency* aCurrency Currencies anInCurr float aRate | ||
| CurrencyController | exchangeCurrency | Currency* aCurrency Currencies anInCurr int anInCurrAmt | ||
| CurrencyController | getAvailCurrency | Currency* aCurrency | int | |
| HWInterface | dispenseCurrency | int anOutAmt | void | |
| HWInterface | setAvailCurrency | Currencies anOutCurr int amount | void | |
| HWInterface | getCurrencyRate | Currencies anInCurr Currencies anOutCurr | void | |
| HWInterface | setCurrencyRate | Currencies anInCurr Currencies anOutCurr float aRate | ||
| HWInterface | exchangeCurrency | Currencies anInCurr Currencies anOutCurr int anInCurrAmt | ||
| HWInterface | getAvailCurrency | Currencies anOutCurr | void |
| Element | Prototype | Production Implementation |
| Processors | Single Processor Intel Processor | Single Processor Intel Processor |
| Devices | Display | HW Equipment |
| Operating System | MS-DOS | MS-DOS |
| Graphic User Interface | Text Only | Text Only |
| Language | C++ | C++ |
| Libraries | N/A | N/A |
| Components/DLLs/EXEs | CURRENCY.EXE | CURRENCY.EXE |
| Processes/Threads/Tasks | N/A | N/A |
| Persistent Data Storage | C++ Streams | TBD |
| Distribution and Connectivity | N/A | N/A |
| Test Cases | 5 | 5 |
| Help/User/Installation Documentation | N/A | Yes |
The Processor - Processes Diagram displays the processor
and concurrent processes in the system as boxes. In the Currency
Control System there is only one processor with a single process.
There is no concurrency.
//Currency Control System C++ Prototype
//Condensed single file C++ prototype for educational
purposes
#include <iostream.h>
enum Currencies { US, DM, FR }; //Global Type
Declaration
///////////////////////////////////////////////////////////////
class Currency { //Base Class
protected:
int availCurrency;
float currencyRates [2];
public:
void setAvailCurrency (int amount){availCurrency
= amount; }
int getAvailCurrency () {return availCurrency;
}
float getCurrencyRate (Currencies anInCurr)
{ return currencyRates [anInCurr]; }
void setCurrencyRate (Currencies anInCurr, float aRate)
{currencyRates [anInCurr] = aRate; }
virtual int exchangeCurrency (Currencies anInCurr, int anInCurrAmt) = 0;
};
////////////////////////////////////////////////////////////////
class USCurrency : public Currency {//Derived Class - Details to
public: // be added
int exchangeCurrency (Currencies anInCurr, int anInCurrAmt)
{ int anOutAmount = anInCurrAmt * currencyRates [anInCurr];
return anOutAmount;}
};
////////////////////////////////////////////////////////////////
class DMCurrency : public Currency { //Derived Class - Details to
public: // be added
int exchangeCurrency (Currencies anInCurr, int anInCurrAmt)
{ int anOutAmount = anInCurrAmt * currencyRates [anInCurr];
return anOutAmount;}
};
///////////////////////////////////////////////////////////////
class CurrencyController {
public:
DMCurrency aDM;
USCurrency aUS;
void setAvailCurrency (Currency *aCurrency, int amount)
{ aCurrency -> setAvailCurrency (amount);
}
float getCurrencyRate (Currency *aCurrency, Currencies anInCurr)
{ float aRate = aCurrency -> getCurrencyRate (anInCurr);
return aRate;}
void setCurrencyRate (Currency *aCurrency, Currencies anInCurr, float aRate)
{ aCurrency -> setCurrencyRate (anInCurr,
aRate); }
int exchangeCurrency (Currency *aCurrency, Currencies anInCurr, int anInCurrAmt)
{ int anOutAmount;
anOutAmount = aCurrency -> exchangeCurrency (anInCurr, anInCurrAmt);
return anOutAmount; }
int getAvailCurrency (Currency *aCurrency)
{int anAmount = aCurrency -> getAvailCurrency ();
return anAmount; }
};
///////////////////////////////////////////////////////////////
class HWInterface {
CurrencyController aCurrencyController;
public:
//void displayStatus (String aString) { } //Calls to cout <<
//simulate calls to displayStatus
void dispenseCurrency (int anOutAmt)
{cout << "The dispensed amount is
" << anOutAmt << ".\n"; }
void setAvailCurrency (Currencies anOutCurr, int amount)
{if (anOutCurr == DM) aCurrencyController.setAvailCurrency
(&aCurrencyController.aDM, amount); }
void getCurrencyRate (Currencies anInCurr, Currencies anOutCurr)
{ float aRate = 0.0;
if (anOutCurr == DM)
{ aRate = aCurrencyController.getCurrencyRate (&aCurrencyController.aDM, anInCurr);
cout << "The current rate is " << aRate << ".\n";}
}
void setCurrencyRate (Currencies anInCurr, Currencies anOutCurr, float aRate)
{ if (anOutCurr == DM)
{ aCurrencyController.setCurrencyRate (&aCurrencyController.aDM, anInCurr, aRate);
cout << "The current rate has been set to " << aRate << ".\n";}
}
void exchangeCurrency (Currencies anInCurr, Currencies anOutCurr, int anInCurrAmt)
{ int anOutAmount;
if (anOutCurr == DM) {
anOutAmount = aCurrencyController.exchangeCurrency (&aCurrencyController.aDM, anInCurr, anInCurrAmt);
dispenseCurrency (anOutAmount);}
}
void getAvailCurrency (Currencies anOutCurr)
{ int anAmount = 0;
if (anOutCurr == DM)
{ anAmount = aCurrencyController.getAvailCurrency (&aCurrencyController.aDM);
cout << "Current available currency is " << anAmount << ".\n"; }
}
};
///////////////////////////////////////////////////////////////
int main () //Test Case
{ HWInterface aHWInterface;
cout << "Setting the available currency for DM - Deutschemarks.\n";
aHWInterface.setAvailCurrency (DM, 1000);
aHWInterface.getAvailCurrency (DM);
cout << "Setting the current exchange rate for DM - Deutschemarks.\n";
aHWInterface.setCurrencyRate (US, DM, 1.5);
aHWInterface.getCurrencyRate (US, DM);
cout << "Exchanging 1 US dollar for Deutschemarks.\n";
aHWInterface.exchangeCurrency (US, DM, 1);
return 0; }
///////////////////////////////////////////////////////////////
//Sample Output
//Setting the available currency for DM - Deutschemarks.
//The available currency is 1000.
//Setting the current exchange rate for DM - Deutschemarks.
//The current rate has been set to 1.5.
//The current rate is 1.5.
//Exchanging 1 US dollar for Deutschemarks.
//The dispensed amount is 1.