Advertisement
axyd

C++ errMacGyver format and ranges

Oct 20th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. // Check for proper data input format, and ranges
  2. void Xclass::errMacGyver(int sku, int qty, double price, int menu, int CASE) {
  3.     auto caZe= &CASE;
  4.     if (cin.fail()) {
  5.         cleanCin();
  6.         return;
  7.     }
  8.  
  9.     if((*caZe)==0 && cin.good()) {
  10.         if(sku<0 || qty<0 || price<0) *caZe=1; //Negative
  11.         if((sku>0 && sku<10000000) || (price>0 && price<0.5)) *caZe=2;  //Too Small
  12.         if(qty>99 || sku>99999999 || price>20000) *caZe=3;  //Too Large
  13.         switchBlade(*caZe);
  14.     } else if ((*caZe)!=0 && (*caZe)!=111 ) switchBlade(*caZe); //directly invoke error message
  15.     else if((menu<1 || menu>6) && (*caZe)==111) switchBlade(*caZe); //menu choice
  16. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement