subject

For this lab you will write a Java program that will run a Dragon Trainers. The rules of the game are simple: each player has three dragons that they have trained, and each dragon is tied to a particular element. Each player has a Fire Dragon, a Water Dragon and a Plant Dragon. Each player picks one dragon to put out in front of them to fight the other player's dragon. Both players choose separately without knowing what the other player has selected. Fire Dragons always beat Plant Dragons, Plant Dragons always beat Water Dragons, and Water Dragons always beat Fire Dragons. If both players choose the same kind of dragon, they tie. Your program will run a series of games of one player against the computer. First the player will be prompted for a random seed and then a number of matches to play. For each match, the computer will pick a random dragon type and the player will enter their choice as a single letter- F for fire, W for water, or 'P' for plant (the program should accept either uppercase or lowercase, and should only care about the first letter of the user's input). The program should then report both choices as well as who the winner is. This process repeats until all of the matches have been played- at that point the program will reporta summary of the matches and decide who won the tournament overall. See the transcripts below for how your output should be formatted.
NOTE if the player enters an invalid choice, the computer wins by default.
NOTE To generate a random choice, you must use the Random object as we have used in the previous labs. You can use it to generate a number between 0 and 2 and assiign each value to a type of dragon A value of 0 will be Fire, 1 will be Plant and 2 will be Water. Note that you MUST use these assignments of numbers to types for your submission to be able to pass the test cases!
NOTE You MUST only declare and instantiate one single Random object to be able to match the test cases And this must be done outside of your main game loop. Note that this is typically how Random objects are used-you create them once and then use the same Random object for your entire program, rather than creating new ones every time you need a new random number.
Here is one example of the game in action. Note that as always, user inputs are in BOLD.
Enter a random seed: 24
How many matches will we play? 3
Please select one of your dragons [Fire/Plant/Water]: Plant
You chose: Plant dragon.
I chose: Plant dragon.
A Tie!
Please select one of your dragons [Fire/Plant/Water]: FIRE
You chose: Fire dragon.
I chose: Plant dragon.
Fire defeats Plant -you win!
Please select one of your dragons [Fire/Plant/Water]: w
You chose: Water dragon.
I chose: Fire dragon.
Water defeats Fire you win!
The tournamont is over!
We tied 1 matches.
I won 0 matches.
You won 2 matches.
You are the winner!
Here is another example of the game in action. Note that if the user enters an invalid response, the computer wins by default. But also note that only the first character of the input matters when determining whether or not the input is valid
Enter a random seed: 33
How many matches will we play? 4
Please select one of your dragona (Fire/Plant/Water]:
You chose: Fire dragon.
I chose: Fire dragon.
A Tie!
Please select one of your dragons [Fire/Plant/Water): pfjlsd
You chose: Plant dragon.
I chose: Fire dragon.
Fire defeats Plant-you lose!
Please select one of your dragons [Fire/Plant/Water]: jkfld
You don't have a jkfld dragon, so you choose no dragons.
I chose: Water dragon.
I win by default!
Please nelect one of your dragons [Fire/Plant/Water]: plnat
You chose: Plant dragon.
I chose: Water dragon.
Plant defeats Water -you win!
Please select one of your dragons [Fire/Plant/Water] plnat
You chose: Plant dragon.
I chose: Water dragon.
Plant defeats Water- you win!
The tournament is over!
We tied 1 matches.
I Won 2 matches.
You won 1 matoches.
I am the winner!
If there is a tie, the final message should indicate that neither player is the winner as in the transcript below
Enter a random seed: 33
How many matches will we play? 1
Please select one of your dragons [Fire/Plant/Water]: Fire
You chose: Fire dragon. Fire dragon.
I chose:
A Tie!
The tournament is over!
We tied 1 matches.
I won 0 matches.
You won 0 matches.
Neither of us can claim victory here!

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
Alocal reaction will occur at the site of the exposure such as irritation or damage to the skin eye or local reaction will occur at the site of the exposure such as irritation or damage to the skin ireland lounges
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
Light travels at a speed of 186,000 miles a second. the distance light travels in a year is 5,865,690,000,000 miles/year 5,865,695,000,000 miles/year 58,656,950,000,000 miles/year 6,789,000,0000 miles/year
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
To check whether your writing is clear , you can
Answers: 2
You know the right answer?
For this lab you will write a Java program that will run a Dragon Trainers. The rules of the game ar...
Questions
question
English, 22.12.2020 01:20
question
Mathematics, 22.12.2020 01:20
question
Mathematics, 22.12.2020 01:20
question
Mathematics, 22.12.2020 01:20
question
Mathematics, 22.12.2020 01:20
question
English, 22.12.2020 01:20
Questions on the website: 13722361