Untitled
unknown
plain_text
3 years ago
3.0 kB
4
Indexable
#include <iostream> #include<cstdlib> #include <ctime> #include <random> using namespace std; // function prototypes void drawSquare(); void drawTriangle(); void drawRectangle(int height, int width); void getShape(); void mainmenu(); void answer(); int getRandomNumber(); int shapeSelection = 0; int getRandomNumber() { // Providing a seed value srand((unsigned)time(NULL)); // Retrieve a random number between 10 and 20 // Offset = 10 // Range = 11 int random = 1 + (rand() % 3); return(random); } void drawSquare() { cout << " ----------\n"; cout << "| |\n"; cout << "| |\n"; cout << "| |\n"; cout << "| |\n"; cout << " ----------\n"; } void drawRectangle(int height, int width) { cout << " ------------------\n"; cout << "| |\n"; cout << "| |\n"; cout << "| |\n"; cout << "| |\n"; cout << " ------------------\n"; } void drawTriangle() { cout << " /\\ \n"; cout << " / \\ \n"; cout << " / \\ \n"; cout << " / \\ \n"; cout << " / \\ \n"; cout << " ---------- \n"; } void guessShape() { int shape; cout << "\n What shape is it? \n"; cout << "----------------- \n"; cout << "a. Rectangle \n"; cout << "b. Triangle \n"; cout << "c.Square \n"; cout << "d.None of the above \n"; cin >> shape; do { switch (shape) { case 'a': drawRectangle(3, 5); break; case 'b': drawTriangle(); break; case 'c': drawRectangle(3, 5); break; case 'd': cout << "Shape Unknown"; break; } } while (shape != 0); } void getShape() { int random = getRandomNumber(); // Use the value of a to determine which shape to draw switch (random) { case 1: drawRectangle(3, 5); break; case 2: drawTriangle(); break; case 3: drawRectangle(3, 5); break; default: cout << "Shape Unknown"; break; } } //Display Main menu void mainmenu() { int selection; cout << " Identify The Shapes \n"; cout << "*********************\n\n"; cout << "1. Play \n"; cout << "2. Final Score \n"; cout << "3. Exit \n"; cin >> selection; if (selection == 1) { getShape(); } else if (selection == 2) { cout << "calc"; } else if (selection == 3) { exit(0); } } void answer() { } int main() { int shapeSelection = 0; int random; mainmenu(); getShape(); guessShape(); }
Editor is loading...