-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInterface.cpp
More file actions
120 lines (112 loc) · 3.02 KB
/
Copy pathUserInterface.cpp
File metadata and controls
120 lines (112 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* @file UserInterface.cpp
* @author Justin
* @brief Class representing the UI for the program.
* @version 0.1
* @date 2018-11-28
*
* @copyright Copyright (c) 2018
*
*/
#include "UserInterface.h"
using namespace std;
/**
* @brief Construct a new User Interface when no parameters are passed.
*
*/
UserInterface::UserInterface(){
}
/**
* @brief Construct a new User Interface with the passed Drink Factory to populate all the possible options.
*
* @param factory
*/
void UserInterface::runMenu(DrinkFactory factory){
Menu tempMenu(factory);
bool loop = true;
while(loop){
int option;
cout << "Drink Options:" << endl;
int i = 0;
//cout << "xxx" << endl;
vector<Drink> drinks = tempMenu.getDrinks();
//cout << "xxx" << endl;
for(; i < drinks.size(); i++){
cout << "(" << i + 1 << ") " << drinks[i].getName() << endl;
}
cout << "(" << ++i << ") " << "Exit" << endl << "Input a number: ";
cin >> option;
cout << endl;
if(option == i){
loop = false;
}
else{
option -= 1;
//cout << option << endl;
if (option >= 0 && option < drinks.size()) {
tempMenu.pourDrink(option);
}
}
}
}
/**
* @brief Method for running the programmed games on the program.
*
* @param factory Drink Factory object containing all of the created games.
*/
void UserInterface::runGames(DrinkFactory factory){
bool loop = true;
while(loop){
char option;
cout << "(1) Shoot Your Shot" << endl << "(2) YOLO" << endl << "(3) Exit" << endl << "Input a number: ";
cin >> option;
cout << endl;
switch (option) {
case '1': {
SYS temp(factory.getDrinks());
temp.ShootYourShot();
break; }
case '2': {
YOLO temp(factory.getDrinks());
temp.randomDrink();
break; }
case '3': {
loop = false;
break; }
}
}
// delete temp;
}
/**
* @brief Main method for the program which runs and creates all required objects to run the program.
*
* @return int
*/
int main(){
DrinkFactory factory("DrinkFile.txt");
UserInterface interface = UserInterface();
//Basic text interface implemented for testing purposes
//GUI to be implemented later on in development
bool loop = true;
while(loop){
char option;
cout << "Main Menu:" << endl << "(1) Drink Menu" << endl << "(2) Game Menu" << endl << "(3) Exit" << endl << "Input a number: ";
cin >> option;
cout << endl;
switch (option) {
case '1': {
interface.runMenu(factory);
break;
}
case '2': {
interface.runGames(factory);
break;
}
case '3': {
cout << "Exiting!";
loop = false;
break;
}
}
}
}