Guest User

Untitled

a guest
Apr 28th, 2019
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.67 KB | None | 0 0
  1. // ****************************************************************************
  2. // Fundamental of Programming - Animal Manu
  3. // Description: This program presents the user with a basic menu
  4. //   and runs a different function for each menu option.
  5. // ****************************************************************************
  6.  
  7. // Include external libraries and dependencies.
  8. #include <iostream>
  9. #include <iomanip>
  10. #include <conio.h>
  11. using namespace std;
  12.  
  13. // Establish constants.
  14. #define TRUE            1
  15. #define FALSE           0
  16. #define MENU_UNSET      -1      // no menu option selected
  17. #define MENU_LOWEST     1       // indicates the value of the lowest menu code
  18. #define MENU_DOG        1       // DOG option...
  19. #define MENU_CAT        2       // CAT option...
  20. #define MENU_BIRD       3       // BIRD option...
  21. #define MENU_MOUSE      4       // MOUSE option...
  22. #define MENU_COW        5       // COW option...
  23. #define MENU_FROG       6       // FROG option...
  24. #define MENU_ELEPHANT   7       // ELEPHANT option...
  25. #define MENU_DUCK       8       // DUCK option...
  26. #define MENU_FISH       9       // FISH option...
  27. #define MENU_SEAL       10      // SEAL option...
  28. #define MENU_FOX        11      // FOX option!!!
  29. #define MENU_EXIT       12      // indicates the user wants to exit
  30. #define MENU_HIGHEST    12      // indicates the value of the highest menu code
  31.  
  32. // Provide function prototypes.
  33. void Main_MENU();
  34. void Feature_DOG();
  35. void Feature_CAT();
  36. void Feature_BIRD();
  37. void Feature_MOUSE();
  38. void Feature_COW();
  39. void Feature_FROG();
  40. void Feature_ELEPHANT();
  41. void Feature_DUCK();
  42. void Feature_FISH();
  43. void Feature_SEAL();
  44. void Feature_FOX();
  45.  
  46. int main() {
  47.     Main_MENU(); //Main Menu function for Animals
  48.  
  49.     _getch();       // pause the screen
  50.     return 0;       // return to OS
  51. }
  52.  
  53. // Provide function definitions
  54. void Main_MENU() {
  55.     while (true) { //Allows the menu to loop
  56.         //Selection variable
  57.         int Selection = 0;
  58.  
  59.         //Title
  60.         cout << "+-----------------------------------------+" << endl;
  61.         cout << "|-------------- ANIMAL MENU --------------|" << endl;
  62.         cout << "+-----------------------------------------+" << endl;
  63.  
  64.         //Animal Menu
  65.         cout << "1.) What does the dog say?" << endl;
  66.         cout << "2.) What does the cat say?" << endl;
  67.         cout << "3.) What does the bird say?" << endl;
  68.         cout << "4.) What does the mouse say?" << endl;
  69.         cout << "5.) What does the cow say?" << endl;
  70.         cout << "6.) What does the frog say?" << endl;
  71.         cout << "7.) What does the elephant say?" << endl;
  72.         cout << "8.) What does the duck say?" << endl;
  73.         cout << "9.) What does the fish say?" << endl;
  74.         cout << "10.) What does the seal say?" << endl;
  75.         cout << "11.) What does the fox say?" << endl;
  76.         cout << "12.) Exit Program" << endl;
  77.  
  78.         //User Prompt
  79.         cout << "Which menu item would you like to execute: ";
  80.         cin >> Selection;
  81.         cout << endl;
  82.  
  83.         //Input Validation for menu selection
  84.         while (Selection > MENU_HIGHEST || Selection < MENU_LOWEST || cin.fail() == TRUE) {
  85.             cout << "That doesn't appear to be a valid option. Please try again..." << endl;
  86.             cin.clear();
  87.             rewind(stdin);
  88.  
  89.  
  90.             cout << "Which menu option would you like to execute: " << endl;
  91.             cin >> Selection;
  92.         }
  93.  
  94.  
  95.         //'If' statements for selection matches
  96.  
  97.         if (Selection == MENU_DOG) {  //If dog is chosen
  98.             Feature_DOG();
  99.             _getch();
  100.         }
  101.         if (Selection == MENU_CAT) { //If cat is chosen
  102.             Feature_CAT();
  103.             _getch();
  104.         }
  105.         if (Selection == MENU_BIRD) { //If bird is chosen
  106.             Feature_BIRD();
  107.             _getch();
  108.         }
  109.         if (Selection == MENU_MOUSE) { //If mouse is chosen
  110.             Feature_MOUSE();
  111.             _getch();
  112.         }
  113.         if (Selection == MENU_COW) { //If cow is chosen
  114.             Feature_COW();
  115.             _getch();
  116.         }
  117.         if (Selection == MENU_FROG) { //If frog is chosen
  118.             Feature_FROG();
  119.             _getch();
  120.         }
  121.         if (Selection == MENU_ELEPHANT) { //If elephant is chosen
  122.             Feature_ELEPHANT();
  123.             _getch();
  124.         }
  125.         if (Selection == MENU_DUCK) { //If duck is chosen
  126.             Feature_DUCK();
  127.             _getch();
  128.         }
  129.         if (Selection == MENU_FISH) { //If fish is chosen
  130.             Feature_FISH();
  131.             _getch();
  132.         }
  133.         if (Selection == MENU_SEAL) { //If seal is chosen
  134.             Feature_SEAL();
  135.             _getch();
  136.         }
  137.         if (Selection == MENU_FOX) { //If fox is chosen
  138.             Feature_FOX();
  139.             _getch();
  140.         }
  141.         if (Selection == MENU_EXIT) { //If exiting is what is desired
  142.             cout << "Now exiting...";
  143.             return;
  144.         }
  145.     }
  146. }
  147. void Feature_DOG() {
  148.     cout << "Dog goes \'WOOF\'." << endl << endl;
  149.     }
  150.  
  151. void Feature_CAT() {
  152.     cout << "Cat goes \'MEOW\'." << endl << endl;
  153. }
  154.  
  155. void Feature_BIRD() {
  156.     cout << "Bird goes \'TWEET\'." << endl << endl;
  157. }
  158.  
  159. void Feature_MOUSE() {
  160.     cout << "And the mouse goes \'SQUEEK\'." << endl << endl;
  161. }
  162.  
  163. void Feature_COW() {
  164.     cout << "Cow goes \'MOO\'." << endl << endl;
  165. }
  166.  
  167. void Feature_FROG() {
  168.     cout << "Frog goes \'CROAK\'." << endl << endl;
  169. }
  170.  
  171. void Feature_ELEPHANT() {
  172.     cout << "And elephant goes \'TOOT\'" << endl << endl;
  173. }
  174.  
  175. void Feature_DUCK() {
  176.     cout << "Duck say \'QUACK\'." << endl << endl;
  177. }
  178.  
  179. void Feature_FISH() {
  180.     cout << "And fish go \'BLUB\'." << endl << endl;
  181. }
  182.  
  183. void Feature_SEAL() {
  184.     cout << "And the seal goes \'OW OW OW\'" << endl << endl;
  185. }
  186.  
  187. void Feature_FOX() {
  188.     cout << endl;
  189.     cout << "What the fox say!!!" << endl;
  190.     cout << "\'Ring-ding-ding-ding-dingeringeding!" << endl;
  191.     cout << "Gering-ding-ding-ding-dingeringeding!" << endl;
  192.     cout << "Gering-ding-ding-ding-dingeringeding!" << endl << endl;
  193.     cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl;
  194.     cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl;
  195.     cout << "Wa-pa-pa-pa-pa-pa-wow!" << endl << endl;
  196.     cout << "Hatee-hatee-hatee-ho!" << endl;
  197.     cout << "Hatee-hatee-hatee-ho!" << endl;
  198.     cout << "Hatee-hatee-hatee-ho!" << endl << endl;
  199.     cout << "Joff-tchoff-tchoff-tchoffo-tchoff!" << endl;
  200.     cout << "Tchoff-tchoff-tchoff-tchoffo-tchoff!" << endl;
  201.     cout << "Joff-tchoff-tchoff-tchoffo-tchoff!\'" << endl << endl;
  202. }
Advertisement
Add Comment
Please, Sign In to add comment