-
Notifications
You must be signed in to change notification settings - Fork 164
feat: added risiko.cpp #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: added risiko.cpp #420
Conversation
| cin >> turns; | ||
| cout << endl; | ||
| while(cin.fail() || turns <= 0){ | ||
| cerr << "ERROR! Turns need to be an integer greater than 0, retry." << endl; | ||
| cin >> turns; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avresti potuto evitare delle istruzioni superflue con un do while();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L'ho fatto in modo tale da mettere in evidenza l'errore all'utente e permettergli di reinserire il valore corretto senza dover ricominciare il programma da capo. Non lo so se con il do while() avrei ottenuto lo stesso risultato e forse sarebbero servite più linee di codice. In caso come avrei dovuto procedere?
| #include <ctime> | ||
| using namespace std; | ||
|
|
||
| //Class Player |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
questo commento è superfluo
| cerr << "ERROR! Players can't share the same colour, retry." << endl; | ||
| } | ||
| else{ | ||
| check = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probabilmente puoi rimuovere la variabile check, potresti usare while(player_1 !== player_2), oppure usi while true e metti un break; al posto di check = true;
Non è il massimo usare while (true) o break, quindi opterei più per la prima soluzione
No description provided.