Guest User

phonemask.cxx

a guest
Mar 7th, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void help()
  5. {
  6.     cout << "TEMPLATES: \n  Icelandic = (+354) ### #### \n  Czech = (+420) ### ### ### \nADD YOUR OWN TEMPLATE: Type /add" << endl << endl;
  7. }
  8.  
  9. int main()
  10. {
  11.     int oti1;
  12.     string num;
  13.     string mask;
  14.     string prefix;
  15.     string result;
  16.     string chonput;
  17.     string otu1;
  18.     string otu2;
  19.     string s1;
  20.     string s2;
  21.     string s3;
  22.     string s4;
  23.     string s5;
  24.     int pos = 0;
  25.     bool same = false;
  26.     bool cont = true;
  27.     bool repeat = true;
  28.     cout << "Enter a phone number, and a formatting mask. Please don't use any special characters in the number. In the mask, substite numbers with hash signs (#). You can also choose from a few presets and save up to five of your own templates for transcribing bigger quantities of numbers. Note that saved templates will not be preserved after you close the application. To see the templates and how to save your own, type /help." << endl << endl;
  29.     while(repeat == true)
  30.     {
  31.         if(same == false)
  32.         {
  33.             cout << "Pease enter the mask or choose your action." << endl;
  34.             getline(cin, chonput);
  35.             if(chonput == "/help")
  36.             {
  37.                 help();
  38.                 cont = false;
  39.             } else if(chonput == "/add")
  40.             {
  41.                 cout << "Enter your custom mask:";
  42.                 getline(cin, otu2);
  43.                 cout << "What slot to save into? answer with an integer." << endl;
  44.                 cout << "s1: " << s1 << "\ns2: " << s2 << "\ns3: " << s3 << "\ns4: " << s4 << "\ns5: " << s5 << endl;
  45.                 cin >> oti1;
  46.                 switch(oti1)
  47.                 {
  48.                     case 1:
  49.                     s1 = oti1;
  50.                     break;
  51.                     case 2:
  52.                     s1 = oti1;
  53.                     break;
  54.                     case 3:
  55.                     s3 = oti1;
  56.                     break;
  57.                     case 4:
  58.                     s4 = oti1;
  59.                     break;
  60.                     case 5:
  61.                     s5 = oti1;
  62.                     break;
  63.                     default:
  64.                     cout << "Invalid input!" << endl;
  65.                 }
  66.                 oti1 = 0;
  67.                 otu2 = "";
  68.             } else if(chonput == "Icelandic" || chonput == "icelandic" || chonput == "Iceland" || chonput == "iceland" || chonput == "Ísland" || chonput == "ísland" || chonput == "íslenskur" || chonput == "Íslenskur" || chonput == "is" || chonput == "IS")
  69.             {
  70.                 mask = "### ####";
  71.             } else if(chonput == "Czech" || chonput == "czech" || chonput =="Český" || chonput == "český" || chonput == "cz" || chonput == "CZ")
  72.             {
  73.                 mask = "### ### ###";
  74.             } else if(chonput == "/stop")
  75.             {
  76.                 cout << "closing the application.";
  77.                 return 0;
  78.             } else if(chonput == "s1")
  79.             {
  80.                 mask = s1;
  81.             }else if(chonput == "s2")
  82.             {
  83.                 mask = s2;
  84.             }else if(chonput == "s3")
  85.             {
  86.                 mask = s3;
  87.             }else if(chonput == "s4")
  88.             {
  89.                 mask = s4;
  90.             }else if(chonput == "s5")
  91.             {
  92.                 mask = s5;
  93.             } else
  94.             {
  95.                 mask = chonput;
  96.             }
  97.         }
  98.        
  99.         cout << "Please now enter the number:" << endl;
  100.         getline(cin, num);
  101.        
  102.         cout << endl << "Number:" << endl;
  103.         for(int i = 0; i <= mask.length(); i++)
  104.         {
  105.             if(mask[i] == '#')
  106.             {
  107.                 cout << num[pos];
  108.                 pos++;
  109.             } else
  110.             {
  111.                 cout << mask[i];
  112.             }
  113.         }
  114.         cout << endl;
  115.         if(pos < num.length())
  116.         {
  117.             cout << "Your number's length didn't match your mask, therefore it didn't get formatted properly." << endl;
  118.         }
  119.         pos = 0;
  120.        
  121.         cout << "Another number?" << endl;
  122.         getline(cin, otu1);
  123.         if(otu1 == "yes" || otu1 == "Yes" || otu1 == "1" || otu1 == "true")
  124.         {
  125.             cout << endl;
  126.         } else
  127.         {
  128.             cout << "closing the application.";
  129.             return 0;
  130.         }
  131.         otu1 = "";
  132.         cout << "Same mask?" << endl;
  133.         getline(cin, otu1);
  134.         if(otu1 == "yes" || otu1 == "Yes" || otu1 == "1" || otu1 == "true")
  135.         {
  136.             cout << "ok";
  137.             same = true;
  138.         } else
  139.         {
  140.             cout << "ok";
  141.             same = false;
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment