-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.cpp
More file actions
63 lines (53 loc) · 1.81 KB
/
MainMenu.cpp
File metadata and controls
63 lines (53 loc) · 1.81 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
/*******************************************************************************
* Author : Jesus Lopez *
* Assignment : Project One Menu *
* Date : 11/5/17 *
* Class : CSC 17-A *
******************************************************************************/
#include "ProjHead.h"
int MainMenu(Stock *s ,Player *p, int day)
{
//Variables
int choice; //Input - Player menu choice.
bool valid; //Calc - Whether option two is valid.
//Display Options
cout << left << fixed << setprecision(2)
<< p->name << " Day: " << day + 1 << endl
<< "Money: $" << setw(10) << p->money
<< "Stocks: $" << p->assets << endl << endl;
cout << "1. Buy Stocks" << endl
<< "2. Sell Stocks" << endl
<< "3. Hold" << endl << endl;
do
{
valid = true;
//Input Validation
cout << "Choose an option: ";
cin >> choice;
while(cin.fail())
{
cout << "Invalid Input. Enter a Valid Option: ";
cin.clear();
cin.ignore();
cin >> choice;
}
while(choice > 3 || choice < 1)
{
cout << "Invalid Input. Enter a Valid Option: ";
cin.clear();
cin.ignore();
cin >> choice;
}
if(choice == 2)
{
valid = StkAmnt(s, day);
if(valid == false)
{
cout << "You do not have any stocks to sell." << endl;
}
}
}
while(valid == false);
system("clear");
return choice;
}