-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.cpp
74 lines (66 loc) · 2.38 KB
/
Menu.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
/*************************************************************
** Program name: Menu.cpp
** Author: Ben Fridkis
** Date: 5/12/2017
** Description: Member function definitions for menu class.
Provides Project 3 specific prompts for
starting game or quitting program.
**************************************************************/
#include "Menu.hpp"
/**************************************************
menu
Prompts user to enter menu selection and returns
user selection.
**************************************************/
int Menu::menu()
{
int userChoice;
//This smart pointer assignment statement will dynamically
//create a local MenuInputValidation object whose member
//function will return validated input (line 49). The shared
//pointer's reference count will decrease to 0 when the object
//goes out of scope, and the managed object's memory will be
//automatically deallocated.
shared_ptr<MenuInputValidation> thisMenuInputValidation =
make_shared<MenuInputValidation>();
cout << "\nEnter Menu Selection:\n" << endl;
//Project 3 specific prompts.
cout << "1. Play Game." << endl;
cout << "2. Quit." << endl;
userChoice = thisMenuInputValidation->menuInputValidation
(2);
userSelection = userChoice;
return userSelection;
}
/**********************************************
getNumberOfSelections
Gets numberOfSelections member variable.
**********************************************/
int Menu::getNumberOfSelections() const
{
return numberOfSelections;
}
/*******************************************
setNumberOfSelections
Sets numberOfSelections member variable.
*******************************************/
void Menu::setNumberOfSelections(int numberOfSelections)
{
this->numberOfSelections = numberOfSelections;
}
/******************************************
getuserSelection
Gets userSelection member variable.
******************************************/
int Menu::getUserSelection() const
{
return userSelection;
}
/**************************************
setUserSelection
Sets userSelection member variable.
**************************************/
void Menu::setUserSelection(int userSelection)
{
this->userSelection = userSelection;
}