Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ****************************************************************************
- // Fundamental of Programming - Animal Manu
- // Description: This program presents the user with a basic menu
- // and runs a different function for each menu option.
- // ****************************************************************************
- // Include external libraries and dependencies.
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- // Establish constants.
- #define TRUE 1
- #define FALSE 0
- #define MENU_UNSET -1 // no menu option selected
- #define MENU_LOWEST 1 // indicates the value of the lowest menu code
- #define MENU_DOG 1 // DOG option...
- #define MENU_CAT 2 // CAT option...
- #define MENU_BIRD 3 // BIRD option...
- #define MENU_MOUSE 4 // MOUSE option...
- #define MENU_COW 5 // COW option...
- #define MENU_FROG 6 // FROG option...
- #define MENU_ELEPHANT 7 // ELEPHANT option...
- #define MENU_DUCK 8 // DUCK option...
- #define MENU_FISH 9 // FISH option...
- #define MENU_SEAL 10 // SEAL option...
- #define MENU_FOX 11 // FOX option!!!
- #define MENU_EXIT 12 // indicates the user wants to exit
- #define MENU_HIGHEST 12 // indicates the value of the highest menu code
- // Provide function prototypes.
- void Main_MENU();
- void Feature_DOG();
- void Feature_CAT();
- void Feature_BIRD();
- void Feature_MOUSE();
- void Feature_COW();
- void Feature_FROG();
- void Feature_ELEPHANT();
- void Feature_DUCK();
- void Feature_FISH();
- void Feature_SEAL();
- void Feature_FOX();
- int main() {
- Main_MENU(); //Main Menu function for Animals
- _getch(); // pause the screen
- return 0; // return to OS
- }
- // Provide function definitions
- void Main_MENU() {
- while (true) { //Allows the menu to loop
- //Selection variable
- int Selection = 0;
- //Title
- cout << "+-----------------------------------------+" << endl;
- cout << "|-------------- ANIMAL MENU --------------|" << endl;
- cout << "+-----------------------------------------+" << endl;
- //Animal Menu
- cout << "1.) What does the dog say?" << endl;
- cout << "2.) What does the cat say?" << endl;
- cout << "3.) What does the bird say?" << endl;
- cout << "4.) What does the mouse say?" << endl;
- cout << "5.) What does the cow say?" << endl;
- cout << "6.) What does the frog say?" << endl;
- cout << "7.) What does the elephant say?" << endl;
- cout << "8.) What does the duck say?" << endl;
- cout << "9.) What does the fish say?" << endl;
- cout << "10.) What does the seal say?" << endl;
- cout << "11.) What does the fox say?" << endl;
- cout << "12.) Exit Program" << endl;
- //User Prompt
- cout << "Which menu item would you like to execute: ";
- cin >> Selection;
- cout << endl;
- //Input Validation for menu selection
- while (Selection > MENU_HIGHEST || Selection < MENU_LOWEST || cin.fail() == TRUE) {
- cout << "That doesn't appear to be a valid option. Please try again..." << endl;
- cin.clear();
- rewind(stdin);
- cout << "Which menu option would you like to execute: " << endl;
- cin >> Selection;
- }
- //'If' statements for selection matches
- if (Selection == MENU_DOG) { //If dog is chosen
- Feature_DOG();
- _getch();
- }
- if (Selection == MENU_CAT) { //If cat is chosen
- Feature_CAT();
- _getch();
- }
- if (Selection == MENU_BIRD) { //If bird is chosen
- Feature_BIRD();
- _getch();
- }
- if (Selection == MENU_MOUSE) { //If mouse is chosen
- Feature_MOUSE();
- _getch();
- }
- if (Selection == MENU_COW) { //If cow is chosen
- Feature_COW();
- _getch();
- }
- if (Selection == MENU_FROG) { //If frog is chosen
- Feature_FROG();
- _getch();
- }
- if (Selection == MENU_ELEPHANT) { //If elephant is chosen
- Feature_ELEPHANT();
- _getch();
- }
- if (Selection == MENU_DUCK) { //If duck is chosen
- Feature_DUCK();
- _getch();
- }
- if (Selection == MENU_FISH) { //If fish is chosen
- Feature_FISH();
- _getch();
- }
- if (Selection == MENU_SEAL) { //If seal is chosen
- Feature_SEAL();
- _getch();
- }
- if (Selection == MENU_FOX) { //If fox is chosen
- Feature_FOX();
- _getch();
- }
- if (Selection == MENU_EXIT) { //If exiting is what is desired
- cout << "Now exiting...";
- return;
- }
- }
- }
- void Feature_DOG() {
- cout << "Dog goes \'WOOF\'." << endl << endl;
- }
- void Feature_CAT() {
- cout << "Cat goes \'MEOW\'." << endl << endl;
- }
- void Feature_BIRD() {
- cout << "Bird goes \'TWEET\'." << endl << endl;
- }
- void Feature_MOUSE() {
- cout << "And the mouse goes \'SQUEEK\'." << endl << endl;
- }
- void Feature_COW() {
- cout << "Cow goes \'MOO\'." << endl << endl;
- }
- void Feature_FROG() {
- cout << "Frog goes \'CROAK\'." << endl << endl;
- }
- void Feature_ELEPHANT() {
- cout << "And elephant goes \'TOOT\'" << endl << endl;
- }
- void Feature_DUCK() {
- cout << "Duck say \'QUACK\'." << endl << endl;
- }
- void Feature_FISH() {
- cout << "And fish go \'BLUB\'." << endl << endl;
- }
- void Feature_SEAL() {
- cout << "And the seal goes \'OW OW OW\'" << endl << endl;
- }
- void Feature_FOX() {
- cout << endl;
- cout << "What the fox say!!!" << endl;
- cout << "\'Ring-ding-ding-ding-dingeringeding!" << endl;
- cout << "Gering-ding-ding-ding-dingeringeding!" << endl;
- cout << "Gering-ding-ding-ding-dingeringeding!" << endl << endl;
- cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl;
- cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl;
- cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl << endl;
- cout << "Hatee-hatee-hatee-ho!" << endl;
- cout << "Hatee-hatee-hatee-ho!" << endl;
- cout << "Hatee-hatee-hatee-ho!" << endl << endl;
- cout << "Joff-tchoff-tchoff-tchoffo-tchoff!" << endl;
- cout << "Tchoff-tchoff-tchoff-tchoffo-tchoff!" << endl;
- cout << "Joff-tchoff-tchoff-tchoffo-tchoff!\'" << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment