Question
Project 04 Sample Ouptut This is a sample transcript of what your program should do. Items in bold are user input and should not be
Project 04 Sample Ouptut
This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program. Note that for full credit your output must be able to match the sample transcript's output EXACTLY for the same inputs - including spacing. In this project some of your output will be randomized so you can't replicate the transcript exactly in your tests - pay attention to the spacing for your submission. Please select one of your dragons [Fire/Plant/Water]: Fire You chose: Fire dragon I chose: Water dragon Water defeats Fire - you lose! Your code will behave differently based on the random value it selects and the choice taken by the user. Here is a second possible execution of this code: Please select one of your dragons [Fire/Plant/Water]: Plant You chose: Plant dragon I chose: Water dragon Plant defeats Water - you win! In the case of a tie, your code should report a tie: Please select one of your dragons [Fire/Plant/Water]: Water You chose: Water dragon I chose: Water dragon A Tie! If the user enters an invalid choice, your code should report an error and the human player loses the game: Please select one of your dragons [Fire/Plant/Water]: q You don't have a q dragon, so you choose no dragons. I chose: Fire dragon You lose by default! Your code should work even if the player only puts in the first letter of their choice: Please select one of your dragons [Fire/Plant/Water]: W You chose: Water dragon I chose: Fire dragon Water defeats Fire - you win! For this assignment you should allow the user to enter either capital or lowercase letters to make their choice: Please select one of your dragons [Fire/Plant/Water]: plant You chose: Plant dragon I chose: Fire dragon Fire defeats Plant - you lose! Please select one of your dragons [Fire/Plant/Water]: PLANT You chose: Plant dragon I chose: Fire dragon Fire defeats Plant - you lose! NOTE: To generate a random choice, you will need to use the Math.random() function as used in Lab 03. You will need to modify it to select an integer value between 1 and 3 and assign Fire, Plant or Water according to the number generated (for example, you might decide that 1 is Fire, 2 is Plant and 3 is Water).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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