Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Text-based-Game/mymenu.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
100 lines (84 sloc)
1.58 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include<iostream> | |
using namespace std; | |
class Mymenu{}; | |
{ | |
private: | |
int formula; | |
int choice; | |
int quantity; | |
int gun = 3; | |
int energy = 2; | |
int life = 5; | |
int ok = 1; | |
char answer; | |
//Mymenu{};(); | |
//~Mymenu{};(); | |
public: | |
void gun() | |
{ | |
cout << "the price of the gun is " << gun << endl; | |
cout << "how many u want?? \n"; | |
cin >> quantity; | |
formula = gun * quantity; | |
cout << "the price is " << formula; | |
} | |
void energy() | |
{ | |
cout << "the price of energy is " << energy << endl; | |
cout << "how many u want?? \n"; | |
cin >> quantity; | |
formula = energy * quantity; | |
cout << "the price is " << formula; | |
} | |
void life() | |
{ | |
cout << "the price of life is " << life << endl; | |
cout << "how many u want?? \n"; | |
cin >> quantity; | |
formula = life * quantity; | |
cout << "the price is " << formula; | |
} | |
void buyAgain() | |
{ | |
cout << "\n" << endl << "do you want to buy anything else? y/n" << endl; | |
cin >> answer; | |
if (answer == 'y') | |
print_menu(); | |
} | |
void print_menu() { | |
//while (ok) | |
//{ | |
cout << "please insert the option " << "\n" << endl; | |
cout << "1)gun""\n"; | |
cout << "2)energy ""\n"; | |
cout << "3)life" << endl; | |
cout << "###############################""\n"; | |
cin >> choice; | |
if (choice == 1) | |
{ | |
gun() | |
} | |
else if (choice == 2) | |
{ | |
energy() | |
} | |
else if (choice == 3) | |
{ | |
life() | |
} | |
else | |
{ | |
cout << "invalid info" << endl; | |
} | |
buyAgain(); | |
} | |
int getLife() | |
{ | |
return life; | |
} | |
}; | |
int main(){ | |
Mymenu menu; | |
menu.print_menu(); | |
} |