Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void resultatAvslut(int[] tärning) {
- int resultat = 0;
- boolean yatzy = false;
- int yatsynummer = 0;
- for (int i = 1; i < tärning.length; i++)
- if (tärning[i] == tärning[i - 1]) {
- yatsynummer += 1;
- }
- if (yatsynummer == 4){
- yatzy = true;
- resultat = 50;
- }
- if (!yatzy) {
- for (int i = 0; i < tärning.length; i++)
- resultat += tärning[i];
- }
- System.out.println("Resultatet för spelarens omgång är " + resultat);
- System.out.println("Nästa spelares tur!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement