Please answer in java language. Do not use private method.
This is to implement the WarGame that discussed in the lecture. Take the WarGame.java from D2L and complete the code. Do NOT change main, printRoundinfo or printRoundResult methods. You can add more methods if it is needed. Provide internal and external documentation • including the design diagram. In this game, in each round the program asks a number from user that stand for a card. It also randomly selects a card for computer. Then it declares the cards that user and computer have chosen followed by the winner. The card with higher rank is the winner and gets one score. The suit of card doesn't matter for winning. If they are tie, the user's total score must be doubled. The program must be executed 10 rounds and then declares the total score of the user. - Ace, Jack, Queen and King must be considered as 1, 11, 12 and 13 respectively. - The following is part of output for one run. . The highlighted data is user inputs. In the main method to call geninput method use the name of class and dot operator, i.e: replace comp=genlnput(); (line8) with comp = WarGame.geninput(); and compile and run the program. What happens? Now remove static modifier in the getinput method's header and compile . the program. What happens? Justify the result. Source code:
Source code: import java.util.Scanner; public class WarGame{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); final int ROUND = 10; int user, comp, score = 0; for (int r=1; r < ROUND +1; ++r) { comp = geninput(); user = getInput(scan); printRoundInfo (r, user, comp); score = printRoundResult(score, user, comp); } System.out.println("End of Game!"); scan.close(); } public static int getInput (Scanner input){ // TODO: prompt user to enter a number between 1 and 52, II then validate and return it } public static int geninput(){ //TODO: generate and return a random integer number between 1 and 52 } public static void printRoundInfo(int r, int user, int comp) { System.out.print("R" +r+":"); System.out.print("Computer card is " + getRank (comp) + " of " + getSuit (comp)); System.out.println("; User card is " + getRank(user) + " of " + getSuit(user)); } public static int printRoundResult(int score, int user, int comp){ int winner = findWinner (user, comp);
//TODO: generate and return a random integer number between 1 and 52 } public static void printRoundinfo(int r, int user, int comp){ System.out.print("R" +r+": "); System.out.print("Computer card is " + getRank (comp) + " of " + getSuit(comp)); System.out.println("; User card is " + getRank (user) + " of " + getSuit(user)); } public static int printRoundResult(int score, int user, int comp){ int winner = findWinner (user, comp); switch (winner){ case 0: score *=2; System.out.println("It's tie - user score is " + score); break; case 1: score +=1; System.out.println("User wins - user score is " + score); break; default: System.out.println("Computer wins - user score is " + score); break; } return score; } public static int findWinner(int user, int comp){ //TODO: find the winner and return -1, 1 or 0 if it is tie, //user wins or computer wins } // add more methods if needed. }