Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I want this homework on java program and if you can also to show me the screenshot when you're finished. The lab objective :

Hi,
I want this homework on java program and if you can also to show me the screenshot when you're finished.

The lab objective: Understand the difference between writing the user defined class template (Player class) and using the class as client ( PlayerApp).

Distinction between static and non static variable and method. While writing your Book class you will practice writing constructor, getter, setter, method and static method and use of static variable.

Part A Create a user-defined class called Player that consists of the data and methods for the Player.

1. (0.15 point) Declare the instance variables for Player name, contractValue and team representing the full name (first and last name) of the player their contract value and the team they play for.

Also declare a class variable allPlayersUnion representing the unions name for all the players, initiated allPlayersUnion as kuonDsa

2. (0.2 point) Create two Constructors - a default constructor that has the following (unknown , 100000.0, Cubs), a non-default constructor that uses input parameters to set all instance variables. Use the setter to set instance variables in the both constructors.

3. (0.15point) Three getter Methods: getName, getContractValue and getAllPlayerUnion - return the name, contractValue, allPlayersUnion.

4. (0.15 point) Three setter methods setContractValue, setName and setTeam that assigns values to the instance variables contractValue, name and team.

5. (0.15 point) A method getLastName that return the player last name. This method searches the index of the space in the name and return the last name as all the characters after the space index.

6. (0.25 points) A method formatedUnion that return the allPlayersUnion as proper noun form, meaning starting with upper case and the rest of the word is lower case.

7. (0.25 points) Create a toString method that return the players information in the following form: name, contractValueFormated, team. The contractValueFormated is a formatted contractValue. To format the contractValue and get contractValueFormated :

First, to create a decimal format object df, that maintain 2 decimal points So now you can format any number to have a pattern of always 2 decimal points.

Then declare contactValueFormated and assign the output of the format method using contractValue as input invoked on df .

Part B- Write a client class, PlayerApp, to test the following of your Building class in this order.

  1. (0.1 point) Prompt the user to enter a players name and read user input as name, then promt user to enter the player contract value and read it as contractValue. Hint : you need to use a Scanner object and scanner method to read user input
  2. (0.1 point) create 2 objects using both constructors; player1 default and player2 (name, contract, Cubs).
  3. (0.1 point) Use the setContractValue to update the player1 to 200000.
  4. (0.1 point) Use the getLastName method to get player2 s last name and print the last name on the console.
  5. (0.1 point) Use the method formatedUnion to get all players union as proper name and print the unions name to the console.
  6. (0.1 point) Use the toString method to get the player2 information and show player2 information to the console

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

=+Is the humor funny?

Answered: 1 week ago

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago