Zadanie - prosty program w Javie

0

Witam! To jest gierka która porównuje karty dwóch graczy. Czy mógłby ktoś mi podpowiedzieć co zrobić żeby wyświetlało który gracz wygrał i który wygrał więcej rund?

public class Exercise3{
 
  public static void main(String[] args){
  
  int[] player1 = {10, 6, 8, 9, 7, 12, 7};
  int[] player2 = {7, 6, 9, 5, 2, 8, 11};
  
  int[]roundNo = {1, 2, 3, 4, 5, 6, 7};
 
  System.out.println("******************************Play Card Busters!****************************** ");
  System.out.println(" ");
  
  for(int i=0; i<roundNo.length; i++){
    if(player1[i] > player2[i]){
	 System.out.println("Round No: " + roundNo[i] + "- " + "Player 1 wins the round: " + player1[i] + " " + "beats " + player2[i]);
	  System.out.println(" ");
       }//if
	
	else if(player1[i] == player2[i]){
	 System.out.println("Round No: " + roundNo[i] + "- " + "Tie! " + player1[i] + " " + "ties with " + player2[i]);
      System.out.println(" ");
	   }//else if
	
	else {
	 System.out.println("Round No: " + roundNo[i] + "- " + "Player 2 wins the round: " + player2[i] + " " + "beats " + player1[i]);
	  System.out.println(" ");
	   }//else
		   
	   
    }//for
   }//main
  }//class
2

Dodaj dwie zmiennie roudnsWonByPlayer1 i roundsWonByPlayer2 i inkrementuj odpowiednią w zależności kto wygrał.

Btw. tablica roundNo chyba nie potrzebna? Nie wystarczy zwykła stała int ?

1

W bloku gdzie jest "Player1 wins" inkrenentuj zmienna roundsWonByPlayer1. To samo z Player2.

1 użytkowników online, w tym zalogowanych: 0, gości: 1