Limited_Ice

my common functions

May 16th, 2021
1,365
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3. //  Function Definitons
  4. void intro(int x) {
  5.  
  6.     string pad;
  7.     string intro = "This Is A Parts Database";
  8.     int cent = (80 - intro.length()) / 2;
  9.     for (int i = 0; i < cent; i++)
  10.         pad += ' ';
  11.  
  12.     cout << setw(x) << setfill('*') << '*' << endl;
  13.     cout << setfill(' ') << right << pad << intro << endl;
  14.     cout << setw(x) << setfill('*') << '*' << endl;
  15.  
  16. }
  17.  
  18. void pad() {
  19.     cout << setw(80) << setfill('*') << '*' << endl;
  20. }
  21.  
  22. int chooseshape() {
  23.     int counter = 0;
  24.     int choice;
  25.     cout << "You have chosen to play with shapes\n\nWould you rather play with a triangle or a rectangle\n1) triangle\n\n2) rectangle" << endl;
  26.     cout << setw(80) << setfill('*') << '*' << endl;
  27.     cout << "your choice: ";
  28.     while (true) {
  29.         cin >> choice;
  30.         cout << setw(80) << setfill('*') << '*' << endl;
  31.         counter += 1;
  32.         if (choice == 1 || choice == 2)
  33.             break;
  34.  
  35.         else if (counter > 2) {
  36.             choice = 3;
  37.             break;
  38.         }
  39.         else
  40.             cout << "select using either numeral \"1\" or \"2\"\nyour choice: " << endl;
  41.     }
  42.     return choice;
  43. }
RAW Paste Data