-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.cpp
105 lines (90 loc) · 3.04 KB
/
request.cpp
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
#include "request.H"
#include "validation.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//an instance of this object is created in manageProgram
/****************************************
PLEASE NOTE THE STRUCTURE OF GET_REQUEST WILL CHANGE
AT PRESENT IT'S TOO LONG AND NEEDS A MAKEOVER.
THAT WILL COME..... ONE DAY.
*****************************************/
//creates instance with default string value None
request::request():
rType("None")
{
}
//destructor
request::~request()
{
}
//The program walks the user through selecting a menu option
int request::getRequest()
{
int currentOption = 0; /*dummy value to initialize user choice variable
currentOption is update according to user choice */
while (currentOption == 0){ //set condition to begin loop
std::cout<< "Please choose from one of the following options:\n(Numeric values only) "<< std::endl;
std::cout << " 1. System Information\n 2. PCB Settings\n 3. Exit\n" << std::endl;
std::cin >> currentOption;
if (currentOption == 1){ /* 1 stores the rType as system to pass to
the invoker to be processed the invoker will
navigate use through system class selections */
ClearScreen();
rType = "System";
return 1;
}
else if (currentOption == 2){ /* option 2 enters the pcb area of the system
for invoker to offer/process all/any options for the
pcb class*/
ClearScreen(); //adds spacing
rType = "PCB"; //rType is modified
return 2;
}
else if (currentOption == 3) //offers option to exit the "system"
{
std::string confirmExit = "";
std::cout << " Please type in 'Yes' to confirm exit of OOSTRTA.\n Press any key to return to Home menu\n\n" << std::endl;
std::cin >> confirmExit;
if(confirmExit == "YES"||confirmExit == "Yes"||confirmExit == "yes")
{
ClearScreen();
std::cout << "\n\n\n\n";
//std::cout <<"tito was gangster";
rType = "exit";
return 77; //dummy value I can confidently say we will not reach in menu options
}
else
{
//std::cout <<"tito was a gangster";
return 3;
}
}
//This else if was yanked from stack overflow user Commander Bubble
else if(!isdigit(currentOption)){ /*if the user enters anything other than a number
this delightful block of code will generate an
error message*/
std::cout << "ERROR, please enter a valid response." << std::endl;
std::cin.clear();
std::cin.ignore(256,'\n');
std::cout << "\n\n\n\n";
currentOption =0;
}
else //if they enter some random number
{
std::cout << "Invalid Option\n\n\n\n";
currentOption =0;
}
}
}
void request::displayRequest()
{
std::cout << rType << std::endl;
}
void request::ClearScreen()
{
std::cout << std::string( 1000, '\n' );
}
std::string request::returnRequest(){
return rType;
}