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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:00, sdonachy7
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
image
Computers and Technology, 23.06.2019 06:40, euniceyi56
How many nibbles can be stored in a 16-bit word?
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, keyonaemanieevans
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
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 in other subjects:

Konu
Chemistry, 29.11.2020 14:10