Create a Console Game System ADT using C++ classes: Game, Console, PS4Pro, and Switch.
Class Diagram: see image.
processStart
Manages the overall flow used by the selected console game system.
process Introduction - pure virtual
Displays a friendly message introducing the customer to the selected console game system store.
processSelection
Displays and uses a neat and easy to understand menu system that allows the customer to select one console game from the selected console game system (display 1 console game per line).
processPayment - virtual
Console accepts $20, $10 // $29 dollars might be entered as
PS4Pro accepts $10, $5, $1 // (2) $10, (1) $5, (4) $1
Switch uses Console processPayment // (0) $20, (3) $10
Prompt the customer for the quantity of each payment value one payment value at a time.
processChange - virtual
Console returns $10, $1 // $17 dollars would be changed as
PS4Pro uses Console processChange // (1) $10, (7) $1
Switch returns $5, $2, $1 // (3) $5, (1) $2, (0) $1
Display the quantity for each change value one change value per line.
processDelivery
Display a friendly message telling the customer their successfully purchased console game is being delivered.
Driver program
Displays and uses a neat and easy to understand menu system that allows the customer to select a console game system: PS4Pro or Switch (display 1 console game system per line).
The console game systems have the following available inventory:
PS4Pro | Switch | ||||
Call of Duty WWII | $54 | 3 | Legend of Zelda | $46 | 3 |
Far Cry 5 | $50 | 4 | Skyrim | $50 | 5 |
God of War | $46 | 5 | Super Mario Odyssey | $57 | 1 |
Red Dead Redemption 2 | $57 | 2 |
All members are "instance" members of classes: Game, Console, PS4Pro, and Switch.
The only public members of classes Game, Console, PS4Pro, and Switch are:
Used to define a single console game instance.
class Game { // Game.h & Game.cpp
friend std::ostream& operator<<(ostream &, const Game &);
public:
Game(const char * = "", const int = 0, const int = 0); // name, price, quantity
~Game();
Game(const Game &);
Game & operator=(const Game &);
string getTitle() const;
int getCost() const;
int getQuantity() const;
void setTitle(const char * = "");
void setCost(const int = 0);
void setQuantity(const int = 0);
private:
std::string title; // game title - C++ string reference
int cost; // game cost in dollars
int quantity; // game quantity
};
Used to define the basic functionality required by a console game system manufacturer.
class Console { // Console.h & Console.cpp
public:
Console(const int = 0); // number of different games - PS4Pro (4) - Switch (3)
~Console(); // provided by PS4Pro and Switch derived classes
void processStart();
protected:
Console(const Console &); // cannot use to instantiate
virtual void process Introduction() = 0; // pure virtual function - MUST be overridden
void processSelection();
virtual void processPayment(); // as needed adjust the arguments and return types
virtual void processChange(); // of the processXXXXXX functions
void process Delivery() const;
const int GAME_OPTIONS; // number of different available games
Game * games; // dynamic array of Game instances - GAME OPTIONS
int selectedGame; // game currently selected
int amountPaid; // customer payment in dollars
class PS4Pro // PS4Pro.h & PS4Pro.cpp
class Switch // Switch.h & Switch.cpp