Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. int ActionGenerator() {
  2.  
  3. bool Verify;
  4. int Action;
  5. Verify = true;
  6.  
  7. while(Verify){
  8. cout << "nSELECIONE UMA ACTION: " << endl;
  9. cout << "[1 = ActionX]n[2 = ActionZ]" << endl;
  10. cin >> Action;
  11.  
  12. if (Action == 1 || Action == 2){
  13. return Action;
  14. Verify = false;
  15.  
  16. }else {
  17. cout << "nACTION INVALIDA !" << endl;
  18. }
  19. }
  20. }
  21.  
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int ActionGenerator() {
  26. int Action;
  27. while(true) {
  28. cout << "nSELECIONE UMA ACTION: " << endl;
  29. cout << "[1 = ActionX]" << endl << "[2 = ActionZ]" << endl;
  30. cin >> Action;
  31. if (Action == 1 || Action == 2){
  32. return Action;
  33. } else {
  34. cout << "nACTION INVALIDA !" << endl;
  35. cin.clear(); //Limpa a flag de erro quando há falha no parse do valor entrado
  36. cin.ignore(); //Limpa o buffer
  37. }
  38. }
  39. }
  40.  
  41. int main() {
  42. cout << ActionGenerator() << endl << "ok" <<endl;
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement