Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here\'s part of my code: //Record Win and Loss and updates private int [] [] gam

ID: 3797775 • Letter: H

Question

Here's part of my code:

//Record Win and Loss and updates

private int [] [] gamesPlayed = new int[8][8];

public void recordWinAndLoss(Team winner, Team loser)

{

   winner.setWins(winner.getWins() + 1);

  

loser.setLosses(loser.getLosses() + 1);

int x = indexOf(winner);

int y = indexOf(loser);

gamesPlayed[x][y] += 1;

gamesPlayed[y][x] += 1;

  

}

//Record a Tie game and updates

public void recordTie(Team teamA, Team teamB)

{

  

teamA.setTies(teamA.getTies() + 1);

teamB.setTies(teamB.getTies() + 1);

int x = indexOf(teamA);

int y = indexOf(teamB);

gamesPlayed[x][y] += 1;

gamesPlayed[y][x] += 1;

}

STEP 4 Now write a method called havePlayedTogether(String team A, String teaml League class that returns a boolean indicating whether or not the teams with the given n have played together or not. You should make use of the gamesPlayed array that you ju in. Once completed, append the following code to the LeagueTestProgram and compi System.out.println (a League have PlayedTogether ("Chicago Bulls "I Celtics")) System.out.println (aLeague have Played Together ("New York Knicks "Detroit Pistons")) System.out.println (aLeague have Played Together Detroit Pistons "Atlanta Hawks") System.out.println (aLeague have PlayedTogether ("Chicago Bulls "I York Knicks'')); System.out.println (aLeague have PlayedTogether ("Atlanta Hawks York Knicks'')); System.out.println (aLeague have PlayedTogether ("Indiana Pacers "Boston Celtics")); System.out.println (a League have Played Together ("Toronto Raptors Jersey Nets")) System.out.println (a League have Played Together ("New Jersey Nets York Knicks'')); System.out.println (a League have PlayedTogether ("Boston Celtics" "Detroit Pistons")) System.out.println (aLeague. have PlayedTogether Detroit Pistons Jersey Nets")) System.out.println (a League have Played Together ("I Love 2017 "Fr System.out.println (a League have Played Together ("Chicago Bulls

Explanation / Answer

import java.util.Scanner; public class Project2 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Choose scissors(0), rock(1), paper(2), or -1 to end the game: "); int user = input.nextInt(); int computer = (int)(Math.random() * 3); { if (user == 0 && computer == 1) System.out.println("User chose scissors. Computer chose rock. Computer wins!"); else if (user == 0 && computer == 2) System.out.println("User chose scissors. Computer chose paper. You win!"); else if (user == 1 && computer == 0) System.out.println("User chose rock. Computer chose scissors. You win!"); else if (user == 1 && computer == 2) System.out.println("User chose rock. Computer chose paper. Computer wins!"); else if (user == 2 && computer == 0) System.out.println("User chose paper. Computer chose scissors. Computer wins!"); else if (user == 2 && computer == 1) System.out.println("User chose paper. Computer chose rock. You win!"); else if (user == 0 && computer == 0) System.out.println("User chose scissors. Computer chose scissors. Its a draw!"); else if (user == 1 && computer == 1) System.out.println("User chose rock. Computer chose rock. Its a draw!"); else if (user == 2 && computer == 2) System.out.println("User chose paper. Computer chose paper. Its a draw!"); else if (user == -1) System.exit(0); } } }

public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Choose scissors(0), rock(1), paper(2), or -1 to end the game: "); int user = input.nextInt(); int computer = (int)(Math.random() * 3); int count = 0; int userWins = 0; int computerWins = 0; int draws = 0; { if (user == 0 && computer == 1) { System.out.println("User chose scissors. Computer chose rock. Computer wins!"); computerWins++; count++; } if (user == 0 && computer == 2) { System.out.println("User chose scissors. Computer chose paper. You win!"); userWins++; count++; } if (user == 1 && computer == 0) { System.out.println("User chose rock. Computer chose scissors. You win!"); userWins++; count++; } if (user == 1 && computer == 2) { System.out.println("User chose rock. Computer chose paper. Computer wins!"); computerWins++; count++; } if (user == 2 && computer == 0) { System.out.println("User chose paper. Computer chose scissors. Computer wins!"); computerWins++; count++; } if (user == 2 && computer == 1) System.out.println("User chose paper. Computer chose rock. You win!"); draws++; count++; } if (user == 0 && computer == 0) { System.out.println("User chose scissors. Computer chose scissors. Its a draw!"); draws++; count++; } if (user == 1 && computer == 1) { System.out.println("User chose rock. Computer chose rock. Its a draw!"); draws++; count++; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote