Player.java This class defines the states and behaviors of any instance of Player. Variables: String playerName...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Player.java This class defines the states and behaviors of any instance of Player. Variables: String playerName - the name of this player (e.g., "Lionel Messi") Once this field is initialized, this field should be immutable. O ■ ● ● int stamina - the stamina of this player O This must always be a value in the range [0, 100]. If the initial stamina is not within the appropriate range, initialize it to a value of 75. Position [] positions the positions on the field that this player specializes in This is represented by an array because a player may be able to play multiple positions. The first element in the array is this player's preferred position. int skillRating - the skill rating of this player O Players on Java FC have a skill rating in the range [40, 100]. Ensure that skillRating is always within the appropriate range. When skillRating is initialized, one of the following statements should be printed: ■ O O O ■ ■ Note that there is a difference between the field and the object being immutable. ■ ■ "Skill rating: Excellent" if the rating is in [90, 100]. "Skill rating: Great" if the rating is in [80, 89]. "Skill rating: Very Good" if the rating is in [70, 79]. "Skill rating: Good" if the rating is in [60, 69]. "Skill rating: Fine" if the rating is in [50, 59]. "Skill rating: Bad" if the rating is in [40, 49]. Note: This should only be printed when skillRating is first initialized (i.e., on construction). If the initial skillRating is not within the appropriate range, set it to 80 and print the appropriate statement. Constructors: A constructor that takes in layerName, stamina, positions, and skillRating. A constructor that takes in playerName and positions and defaults stamina to 75 and skillRating to 80. A constructor that takes in no arguments and defaults playerName to "Lionel Messi", stamina to 75, positions to an array of length 1 containing FORWARD, and skillRating to 100. ● Note: O O O Methods: Constructor parameters should be written in the order described above. You may assume that the playerName input will not be null. You may assume that the positions input will not be null nor contain null or duplicate elements. If the input array is empty, initialize positions to an array of length 1 containing MIDFIELDER. isTrainable This method returns true if this player's skill rating is in [50, 89], and false otherwise. O ● ● preferredPosition O This method returns this player's preferred position (i.e., the first element in the positions array). canPlayAs O This method takes in a Position and returns true if the player can play in this position, and false otherwise. toString O O This method returns a String representation of this Player. The string must be formatted as follows (with angle brackets, without curly braces, without spaces between commas, and without trailing whitespace): <{valuel}, {value2}, {value3}, {value4}, {value5}> ▪ The {valueN} should be displayed in the following order: playerName, stamina, preferredPosition (), skillRating, isTrainable () O You must use the String.format method (do not use string concatenation). Getters and setters only as necessary. Any helper methods that you may need; ensure that these methods are not accessible outside of this class. Player.java This class defines the states and behaviors of any instance of Player. Variables: String playerName - the name of this player (e.g., "Lionel Messi") Once this field is initialized, this field should be immutable. O ■ ● ● int stamina - the stamina of this player O This must always be a value in the range [0, 100]. If the initial stamina is not within the appropriate range, initialize it to a value of 75. Position [] positions the positions on the field that this player specializes in This is represented by an array because a player may be able to play multiple positions. The first element in the array is this player's preferred position. int skillRating - the skill rating of this player O Players on Java FC have a skill rating in the range [40, 100]. Ensure that skillRating is always within the appropriate range. When skillRating is initialized, one of the following statements should be printed: ■ O O O ■ ■ Note that there is a difference between the field and the object being immutable. ■ ■ "Skill rating: Excellent" if the rating is in [90, 100]. "Skill rating: Great" if the rating is in [80, 89]. "Skill rating: Very Good" if the rating is in [70, 79]. "Skill rating: Good" if the rating is in [60, 69]. "Skill rating: Fine" if the rating is in [50, 59]. "Skill rating: Bad" if the rating is in [40, 49]. Note: This should only be printed when skillRating is first initialized (i.e., on construction). If the initial skillRating is not within the appropriate range, set it to 80 and print the appropriate statement. Constructors: A constructor that takes in layerName, stamina, positions, and skillRating. A constructor that takes in playerName and positions and defaults stamina to 75 and skillRating to 80. A constructor that takes in no arguments and defaults playerName to "Lionel Messi", stamina to 75, positions to an array of length 1 containing FORWARD, and skillRating to 100. ● Note: O O O Methods: Constructor parameters should be written in the order described above. You may assume that the playerName input will not be null. You may assume that the positions input will not be null nor contain null or duplicate elements. If the input array is empty, initialize positions to an array of length 1 containing MIDFIELDER. isTrainable This method returns true if this player's skill rating is in [50, 89], and false otherwise. O ● ● preferredPosition O This method returns this player's preferred position (i.e., the first element in the positions array). canPlayAs O This method takes in a Position and returns true if the player can play in this position, and false otherwise. toString O O This method returns a String representation of this Player. The string must be formatted as follows (with angle brackets, without curly braces, without spaces between commas, and without trailing whitespace): <{valuel}, {value2}, {value3}, {value4}, {value5}> ▪ The {valueN} should be displayed in the following order: playerName, stamina, preferredPosition (), skillRating, isTrainable () O You must use the String.format method (do not use string concatenation). Getters and setters only as necessary. Any helper methods that you may need; ensure that these methods are not accessible outside of this class.
Expert Answer:
Answer rating: 100% (QA)
Step 1 Here is a simple Introduction The Player class models a soccer player with immutable attributes like name stamina positions and skill rating providing methods to access validate and display pla... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
what ways do calligraphers engage with digital technologies and software to augment their creative process or facilitate collaboration in the modern age ?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the case study and answer the question below with a one page response. What does a SWOT analysis reveal about the overall attractiveness of Under Armours situation? Founded in 1996 by former...
-
The enzyme Stell participates in several distinct MAP kinase signaling pathways in the budding yeast S. cerevisiae. What is the substrate for Ste 11 in the mating factor signaling pathway? When a...
-
Determine the force in each member of the truss and indicate whether the members are in tension or compression. Units Used: kip = 1000 lb Given: F1 = 1000 lb F2 = 500 lb a = 4 ft b = 8 ft c = 4 ft F2
-
A student, who weighs 746N on earth, travels to another planet where she weighs 425N. You may enter answers in scientific notation as shown: 1.23 x 105 = 1.23e5 What is the student's mass? 74.6 kg...
-
Use the wine quality data in Table B. 11 to construct a regression model for quality using the stepwise regression approach. Compare this model to the one you found in Problem 10.4, part a. Data From...
-
Myer Food in Bowling Green, Kentucky, manufactures and markets snack foods. Mila Giles manages the company's fleet of 220 delivery trucks. Giles has been charged with "reengineering" the...
-
Dickinson Company has $12,080,000 million in assets. Currently half of these assets are financed with long-term debt at 10.4 percent and half with common stock having a par value of $8. Ms. Park,...
-
The financial statements at the end of Wolverine Realtys first month of operations are as follows: Instructions By analyzing the interrelationships among the four financial statements, determine the...
-
An investor has a budget of $10 million. He can invest in the projects shown. If the cost of capital is 5%, what investment or investments should he make? Project A Project B Project C Project D...
-
log 34.1 Use a calculator to evaluate each expression. Round your answers to three decimal places.
-
Critically assess and analyse substantive and procedure principles underlying the 1997 Watercourse Convention including existing case law.
-
Which aspects of the management of hazardous waste are more developed at the international level? Which less so?
-
log 13.2 Use a calculator to evaluate each expression. Round your answers to three decimal places.
-
Explain the judgments of the ICJ in the Pulp Mills and Costa Rica v. Nicaragua cases in relation to substantive/procedural requirements concerning water cooperation.
-
A bottle of water is placed in a refrigerator and the temperature inside the refrigerator remains constant at 3C. At t minutes after the bottle is placed in the refrigerator, the temperature of the...
-
Identify the tax issues or problems suggested by the following situations. State each issue as a question. Jennifer did not file a tax return for 2007 because she honestly believed that no tax was...
-
Write a default constructor and a second constructor for the class RatingScore, as described in Exercise 9 of the previous chapter. Exercise 9 Consider a class RatingScore that represents a numeric...
-
Repeat the previous programming project, but read the input data from a file and send the output to another file. If you have covered binary files, use binary files; otherwise, use text files. Read...
-
Define DiscountPolicy as an interface instead of the abstract class described in Exercise 10. Exercise 10. Create an abstract class DiscountPolicy. It should have a single abstract method...
-
A construction contract differs from contracts that we generally deal with that focus on an easily defined physical object because the physical object can be examined. How is the object of a...
-
What does the owner contribute to the project and what does the contractor contribute to the project?
-
For what type of project is a line-of-balance schedule particularly suited? Identify specific examples.
Study smarter with the SolutionInn App