Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Tasks 1. Write a complete Java program that is broken down into the main method (of course) and private static methods. The program should

Assignment Tasks

1. Write a complete Java program that is broken down into the main method (of course) and private static methods. The program should start by getting some input from the user where the input values are validated as shown below: String -> Player A name (i.e. Evert or Chris Evert) String -> Player B name (i.e. Graf or Steffi Graf) int -> Number of sets to be played maximum (must either be set to 3 or 5) int -> Starting bias value to use (must be a value from 0 .. 100) where it would be set to 50 if the two players were evenly matched Make a decision on how you can practically handle the situation if invalid inputs are given for the number of sets or the starting bias value. Which of these inputs can be used for testing your program? What kind of tests can you plan to do for when your program is finished?

2. Plan, design and write the program where individual tasks which are done repeatedly (or more than once) are made into separate methods. Please note that the randomDigit method that was written in the class exercise can be reused for this assignment. If you are unfamiliar with how a tennis match is scored then you will need to work through how it all works before you start programming. Your program should keep track of the score after each point is played, print out the game score after each point, and display which player wins each game, set and the match. Your program does not need to keep track of who is serving (which is irrelevant, only who wins each point matters here), or calling out the score where the servers name goes first. Just use Player A (represented by 0s in the data) which always goes first and Player B (represented by 1s) when printing/calling the score. There are two modifications to actual/real tennis scoring that need to be changed to simplify your program. The first is how the score is called out after a point has been played at deuce (score is tied at 40-40). Normally, if the server won the point then the score would be Ad In (with Ad Out meaning the returner won the point at deuce). In your program, the score can instead include the player who wins the point at deuce (so you can use Ad Player A or Ad Player B, or you can insert the players name for the A/B). The second change will go back in time before the modern tiebreaker was invented. In other words, your program does not need to include a tiebreaker (which has its own, completely different scoring system). Instead, as we are not keeping track of who is serving, if a set is tied at 6-6 then whoever wins the next game wins the set 7-6.

3. Example - Your program should indicate who won each point and print out the score, until the match is complete. For example, if Player A is Borg and Player B is McEnroe, and the bias is set to start at 0 (which means that Borg would win every point), then the score would be displayed as follows: Start of play - Borg vs McEnroe - best out of 5 sets Point Borg, Game Score: 15 - Love Point Borg, Game Score: 30 - Love Point Borg, Game Score: 40 - Love Point Borg, Game Borg Set Score: 1 - 0 . . . and so on until the first set is finished . . . Point Borg, Game Borg Set Borg: 6 - 0 Example - If the bias was instead set to 50 (meaning there is a 50-50% chance that either player wins each point) and the random binary digits generated are [0110101011] meaning it took 10 points to complete the first game, then the score displayed would be: Start of play - Borg vs McEnroe - best out of 5 sets Point Borg, Game Score: 15 - Love Point McEnroe, Game Score: 15 - 15 Point McEnroe, Game Score: 15 - 30 Point Borg, Game Score: 30 - 30 Point McEnroe, Game Score: 30 - 40 Point Borg, Game Score: Deuce Point McEnroe, Game Score: Ad McEnroe Point Borg, Game Score: Deuce Point McEnroe, Game Score: Ad McEnroe Point McEnroe, Game McEnroe Set Score: 0 - 1 . . . and so on until the first set is finished . . .

Point McEnroe, Game McEnroe Set McEnroe: 3 - 6

4. Update/Add to your program so that the bias value starts with the value provided as input, but changes after each point is played. If the random binary digit comes out to be 0 then Player A won the point and the bias value can be decreased by 1. If the random binary digit comes out to be 1 then Player B won the point and the bias value can be increased by 1. Furthermore, winning a game changes the bias value by 2 in that players favor, and winning a set changes the bias value by 5. In the second example above, the bias value was said to have started at 50. After the first game has been completed, what would the bias value be set to before the first point of the second game? Which player would be favored at this point in the match?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago