Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Project 04 Extra Credit For up to two points of Extra Credit, modify the game to represent a tournament of dragon trainers. Instead of just
Project 04 Extra Credit For up to two points of Extra Credit, modify the game to represent a "tournament" of dragon trainers. Instead of just playing one game and ending, play until one player has won two games, then show the final score as well as the total number of matches played. Note that you will need to include a loop in your code to make this work Please 8@1@es on of your dragons l Fire/Plant/Hatarj: yse Yau chose Fire dragon I chose: Water dragon Please select one of your dragons rire/Plant Mater Plant Yau chosa: Plant dragon I choser Water dragon Flense eelect one of your dragons Irire/Flant/Materl: Water You chose: Wator dragon I chaset ater draqon A riel Flease eelect one of your dragons Fire/Flant/Materli Water x*u h*8@ ; ilet-r dr@gon I choae: Fire dragon ater defeate rire - you win! Out at 4 matches you won 2, I w 1, and we tied 1 Congratulation you win the tournamentl public static void main(String [] args) 9 10 Scanner keyboard-new Scanner(System.in); 12 13 14 15 16 17 18 19 20 21 int a-3; int b-(int) (Math. random ()a) +1; int CW - 0; int UW = 0; String User-null; String Computernull; //Assign 1 to the Fire, 2 to the Plant, and the 3 to the Water D if(be-1 ) Computer-"Fire"; Computer-"Plant"; Computer-"Water"; if(bs-2 ) 23 24 25 26 27 28 29 30 31 if(b=3) //User enter the type of the dragon System.out.println("Plaese selevt one of your dragons [Fire/Plan String Dragon; Dragon-keyboard.nextLine(); //User enter the type of the dragon System.out.printn("Plaese selevt one of your dragons (Fire/Plant/waterl: "; String Dragon; Dragon keyboard.nextine) //Use if-statement to determine which type of dragon the user chose while ( CW-2LLUWe2 ) f (Dragon. equalsignorecase("Fire" ) 1 1 Dragon. equalsignoreCase("F")) User-"Fire"; System.out.println("You chose: Fire Dragon ") System.out.println("I chose: "Computer"dragon"); else if(Dragon.equalsIgnoreCase("Plant") ||Dragon.equalsIgnoreCase("P")) User-"Plant" System.out.println("You chose: Plant Dragon") System.out.println("I chose: "+Computer" dragon"); else if(Dragon.equalsIgnoreCase("Water") ||Dragon.equalsIgnoreCase("W")) User-"Water"'; System.out.println("You chose: Water Dragon"); System.out.println("I chose : " + Computer + " dragon"); else User Dragon; System.out.println("You don't have a "User"dragon, so you chose no dragon") System.out.println("I chose: "Computer "dragon") System.out.println("You lose by default.") CW CW+1; //Generate results if (Computer. ContentEquals ("Fire" )&&User. contentEquals ("Plant" ) ) System.out.println("Fire defeats Plant you lose!"); CW-CW+1; else if(Computer.contentEquals ("plant")&&User.contentEquals("Fire")) System.out.println("Fire defeats Plant - you win!"); UW-UW+1; else if(Computer.contentEquals("Fire")&&User.contentEquals ("Water")) System.out.println("Water defeats Fire - you win!") UW-UW+1; else if(Computer.contentEquals("Water")&&User.contentEquals("Fire")) System.out.println("Water defeats Fire - you lose!" CW-CW+1; else if(Computer.contentEquals("Plant")&&User.contentEquals ("Water")) System.out.println( "Water defeats Plant - you win!"); UW-UW+1; else if(Computer.contentEquals ("Water")&&User.contentEquals ("Plant")) System.out.println( "Water defeats Plant you lose!") CW-CW+1; else if(Computer.contentEquals("Fire")&&User.contentEquals("Fire")) System.out.println("A Tie!"); else if(Computer.contentEquals("Water")&&User.contentEquals ("Water")) System.out.println("A Tie"); else if(Computer.contentEquals("Plant")&&User.contentEquals("Plant")) System.out.println("A Tie!"); System.out.println("User wins .. + UW + .. times ) ; System.out.println("Computer wins: "CW +"times."); System.out.println("End game.")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started