For this lab you will fill in the skeleton of 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 report a 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, this code uses the Random object as we have used in the previous labs. A value of 0 will be Plant, 1 will be Water and 2 will be Fire. 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 the main game loop and in the main method. Your methods should NOT create their own Random object. 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.
NOTE You MUST only declare and instantiation on single Scanner object to be able to run the test cases. And this must be done outside of the main game loop and in the main method. Your methods should NOT create another Scanner object but instead should use the one passed in as a parameter. Note that this is also typically how Scanner objects get used – you create them once and then use the same Scanner object for your entire program.
Note that this “skeleton” of code in the template includes a main method that has already been written for you. Read the main method and make sure you understand what it is doing and how it is calling the other methods in the program. Comments are included to help you understand what each piece of the code is supposed to be accomplishing. DO NOT CHANGE THE CODE IN THE MAIN METHOD TO GET YOUR SOLUTION TO WORK! Full credit for the assignment will only be earned if you can get the code to work without changing the main method provided.
Here is one example of the game in action. Note that as always, user inputs are in BOLD:
Enter a random seed: 33
How many matches will we play? 3
Please select a dragon [Plant/Water/Fire]: F
I chose: Plant dragon.
You chose: Fire dragon.
Fire defeats Plant – you win!

Please select a dragon [Plant/Water/Fire]: W
I chose: Plant dragon.
You chose: Water dragon.
Plant defeats Water – you lose!

Please select a dragon [Plant/Water/Fire]: P
I chose: Fire dragon.
You chose: Plant dragon.
Fire defeats Plant – you lose!

The tournament is over!
We tied 0 matches.
I won 2 matches.
You won 1 matches.
I am 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: 24
How many matches will we play? 3
Please select a dragon [Plant/Water/Fire]: f
I chose: Water dragon.
You chose: Fire dragon.
Water defeats Fire – you lose!

Please select a dragon [Plant/Water/Fire]: alsdf
I chose: Water dragon.
You don’t have the alsdf dragon.
So no dragon fights for you.
I win by default!

Please select a dragon [Plant/Water/Fire]: pfjslkd
I chose: Plant dragon.
You chose: Plant dragon.
A Tie!

The tournament is over!
We tied 1 matches.
I won 2 matches.
You won 0 matches.
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 a dragon [Plant/Water/Fire]: P
I chose: Plant dragon.
You chose: Plant dragon.
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!

Note that if the user enters a non-positive value for the number of matches, the program should reject it and make them enter a positive value, and if the user enters a blank line for the dragon the program should reject it and make them enter some non-empty value:
Enter a random seed: 33
How many matches will we play? 0
ERROR – number of matches must be positive!
How many matches will we play? -1
ERROR – number of matches must be positive!
How many matches will we play? 1
Please select a dragon [Plant/Water/Fire]:
ERROR – Dragon prompt cannot be empty.
Please select a dragon [Plant/Water/Fire]: P
I chose: Plant dragon.
You chose: Plant dragon.
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!

You MUST use the skeleton for your code. Your solution must include the implementation and use of all of the methods defined in this skeleton – think about what each method does and how it relates to the program overall. You MUST NOT make any changes to the main method – violating any of these requirements will cause a deduction in the points earned. Remember – a goal for this assignment is to practice writing methods that conform to a particular specification! The test cases for this program are written to let you test the individual methods as well as the final output. Test incrementally! Write one method at a time and then test it rather than waiting until you’ve written the whole program and testing it all at once! Taking an incremental approach will help you keep the whole assignment manageable by tackling it in pieces. Note also that you can complete the methods in any order.
The messages for the various win conditions are:
Computer win: I am the winner!
Player win: You are the winner!
A tie game: Neither of us can claim victory here!

NOTE The template includes a private constant array named DRAGONS. The order of the Strings in the array DRAGONS matches the mapping of ints to dragon types required by this assignment. Since DRAGONS is declared at the class level – outside of any method – it is in scope for all of the methods in the class. You should use this array in your solutions, but do NOT change the values in this array when you run your solution.
NOTE 2: It is easy to write an overly complex determineWinner method if you think about it as checking every possible combination of choices for the player and the computer. If you think about the order required and given in the array in the code, you can see that it has been purposefully set up so that they are in a particular order. The dragon type at position 1 is beaten by the type at position 0, the type at position 2 is beaten the type at position 1, and the type at position 0 is beaten by the type at position 2. Notice that this is NOT strictly “the bigger index is beaten by the opponent”, nor is it exactly “you beat your opponent if your index is exactly 1 smaller than their index”, but there is a fairly elegant way to the comparisons without just “brute forcing” all of the possible combinations. Think about how to write a determineWinner method that makes use of this ordering instead of just brute forcing all of the possible combinations in a giant if-else-if-else statement. HINT One approach involves the fact that the winner of the pair is exactly one smaller than the loser in 2 of the 3 cases.
Get professional assignment help cheaply
Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?
Whichever your reason may is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.
Our essay writers are graduates with diplomas, bachelor, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college diploma. When assigning your order, we match the paper subject with the area of specialization of the writer.
Why choose our academic writing service?

Plagiarism free papers
Timely delivery
Any deadline
Skilled, Experienced Native English Writers
Subject-relevant academic writer
Adherence to paper instructions
Ability to tackle bulk assignments
Reasonable prices
24/7 Customer Support
Get superb grades consistently

 

Get Professional Assignment Help Cheaply
Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?
Whichever your reason may is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.
Our essay writers are graduates with diplomas, bachelor’s, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college diploma. When assigning your order, we match the paper subject with the area of specialization of the writer.
Why Choose Our Academic Writing Service?

Plagiarism free papers
Timely delivery
Any deadline
Skilled, Experienced Native English Writers
Subject-relevant academic writer
Adherence to paper instructions
Ability to tackle bulk assignments
Reasonable prices
24/7 Customer Support
Get superb grades consistently

How It Works
1.      Place an order
You fill all the paper instructions in the order form. Make sure you include all the helpful materials so that our academic writers can deliver the perfect paper. It will also help to eliminate unnecessary revisions.
2.      Pay for the order
Proceed to pay for the paper so that it can be assigned to one of our expert academic writers. The paper subject is matched with the writer’s area of specialization.
3.      Track the progress
You communicate with the writer and know about the progress of the paper. The client can ask the writer for drafts of the paper. The client can upload extra material and include additional instructions from the lecturer. Receive a paper.
4.      Download the paper
The paper is sent to your email and uploaded to your personal account. You also get a plagiarism report attached to your paper.

 

PLACE THIS ORDER OR A SIMILAR ORDER WITH Essay fount TODAY AND GET AN AMAZING DISCOUNT

The post Dragon Trainers With Methods appeared first on Essay fount.


What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."


"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"