Skip to content

Conversation

@Dani220406
Copy link

No description provided.

Comment on lines +152 to +157
cin >> turns;
cout << endl;
while(cin.fail() || turns <= 0){
cerr << "ERROR! Turns need to be an integer greater than 0, retry." << endl;
cin >> turns;
}
Copy link
Collaborator

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();

Copy link
Author

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
Copy link
Member

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;
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants