In sample steps plz For the question below, write the reuested portions of a cla
ID: 3684095 • Letter: I
Question
In sample steps plz For the question below, write the reuested portions of a class called employee an employee will have a name, social securitynumber, position and hourly wages. Define the instance data for this class For the question below: Assume this box class: Write the statement to instantiate an box object, bluebox, with a length of 6, width of 4, and height of Write a statement to output the volume of the blue box. Write a statement to instantiate a cube with a length of 3. width of 3, and height of 3. Write a class called NumberOfPlayers that represents the total number of players m a basketball The NumbetOfplayers class should contain 4 instance data. Jersey number or a player. color of Jersey worn, name of player and position played by a player Write a constructor to initialise the jersey number to Zero, jersey color green, position as forward and name of player ax Doctor.. Create a NumboOfPlaycrs object whose jency number is color of jersey while, name is class test and play as a guard Print the name. jersey color. jersey number and the position of the object createdExplanation / Answer
Program:
public class NumberOfPlayers {
int jerseyNumber;
String jerseyColor;
String name;
String position;
private static NumberOfPlayers obj1;
public NumberOfPlayers(){
jerseyNumber=0;
jerseyColor="green";
position="forword";
name="Doctor";
}
public NumberOfPlayers(int jn, String color, String playerName, String playerPosition){
jerseyNumber=jn;
jerseyColor=color;
position=playerPosition;
name=playerName;
}
String getName(){
return name;
}
int getjerseyNumber(){
return jerseyNumber;
}
String getjerseyColor(){
return jerseyColor;
}
String getPosition(){
return position;
}
public static void main(String str[]){
obj1=new NumberOfPlayers(10,"White","classTest","gaurd");
System.out.println("Player Name : "+obj1.getName());
System.out.println("Jersey Color : "+obj1.getjerseyColor());
System.out.println("Jersey Number : "+obj1.getjerseyNumber());
System.out.println("Player Position : "+obj1.getPosition());
}
}
Result:
Player Name : classTest
Jersey Color : White
Jersey Number : 10
Player Position : gaurd
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.