Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Create a UML Diagram for classes below // Player.java public class Player { //attributes private int id; private String playerName; private String teamName; private String

Create a UML Diagram for classes below

// Player.java

public class Player {

//attributes

private int id;

private String playerName;

private String teamName;

private String position;

private double salary;

private double commisionRate;

//def constructor

public Player() {

id=0;

playerName="";

teamName="";

position="";

salary=0;

commisionRate=0;

}

//parameterized constructor

public Player(int id, String playerName, String teamName, String position,

double salary, double commisionRate) {

this.id = id;

this.playerName = playerName;

this.teamName = teamName;

this.position = position;

this.salary = salary;

this.commisionRate = commisionRate;

}

//getters and setters

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getPlayerName() {

return playerName;

}

public void setPlayerName(String playerName) {

this.playerName = playerName;

}

public String getTeamName() {

return teamName;

}

public void setTeamName(String teamName) {

this.teamName = teamName;

}

public String getPosition() {

return position;

}

public void setPosition(String position) {

this.position = position;

}

public double getSalary() {

return salary;

}

public void setSalary(double salary) {

this.salary = salary;

}

public double getCommisionRate() {

return commisionRate;

}

public void setCommisionRate(double commisionRate) {

this.commisionRate = commisionRate;

}

/**

* calculates and return the commision

*/

public double calculateCommision(){

return salary*commisionRate;

}

}

// BaseballPlayer.java

public class BaseballPlayer extends Player {

// constant for storing the limit for determining status

public static final double STATUS_THRESHOLD = 0.25;

//extra attributes

private int numberOfHits;

private int numberOfTimesAtBat;

//def constructor

public BaseballPlayer() {

super();

numberOfHits = 0;

numberOfTimesAtBat = 0;

}

public BaseballPlayer(int id, String playerName, String teamName,

String position, double salary, double commisionRate,

int numberOfHits, int numberOfTimesAtBat) {

/**

* passing values to super class

*/

super(id, playerName, teamName, position, salary, commisionRate);

this.numberOfHits = numberOfHits;

this.numberOfTimesAtBat = numberOfTimesAtBat;

}

/*getters and setters*/

public int getNumberOfHits() {

return numberOfHits;

}

public void setNumberOfHits(int numberOfHits) {

this.numberOfHits = numberOfHits;

}

public int getNumberOfTimesAtBat() {

return numberOfTimesAtBat;

}

public void setNumberOfTimesAtBat(int numberOfTimesAtBat) {

this.numberOfTimesAtBat = numberOfTimesAtBat;

}

/**

* calculates and return the stats

*/

public double calculateStatistics() {

if (numberOfTimesAtBat == 0) {

/**

* in case if number of times batted is 0, returning 0, or else it

* will cause an ArithmeticException when divided by zero

*/

return 0;

}

return (double) numberOfHits / numberOfTimesAtBat;

}

/**

* returns true of stats > limit , else false

*/

public boolean determineStatus() {

if (calculateStatistics() > STATUS_THRESHOLD) {

return true;

} else {

return false;

}

}

}

// BasketballPlayer.java

public class BasketballPlayer extends Player {

// constant for storing the limit for determining status

public static final double STATUS_THRESHOLD=0.32;

//extra attributes

private int numberOfShotsMade;

private int numberOfShotsAttempted;

public BasketballPlayer() {

super();

numberOfShotsMade = 0;

numberOfShotsAttempted = 0;

}

public BasketballPlayer(int id, String playerName, String teamName,

String position, double salary, double commisionRate,

int numberOfShotsMade, int numberOfShotsAttempted) {

/**

* passing data to super class

*/

super(id, playerName, teamName, position, salary, commisionRate);

this.numberOfShotsAttempted = numberOfShotsAttempted;

this.numberOfShotsMade = numberOfShotsMade;

}

public int getNumberOfShotsMade() {

return numberOfShotsMade;

}

public void setNumberOfShotsMade(int numberOfShotsMade) {

this.numberOfShotsMade = numberOfShotsMade;

}

public int getNumberOfShotsAttempted() {

return numberOfShotsAttempted;

}

public void setNumberOfShotsAttempted(int numberOfShotsAttempted) {

this.numberOfShotsAttempted = numberOfShotsAttempted;

}

/**

* calculates and return the stats

*/

public double calculateStatistics() {

if (numberOfShotsAttempted == 0) {

/**

* in case if number of shots attempted is 0, returning 0, or else it

* will cause an ArithmeticException when divided by zero

*/

return 0;

}

return (double) numberOfShotsMade / numberOfShotsAttempted;

}

/**

* returns true of stats > limit , else false

*/

public boolean determineStatus() {

if (calculateStatistics() > STATUS_THRESHOLD) {

return true;

} else {

return false;

}

}

}

// FootballPlayer.java

public class FootballPlayer extends Player {

// constant for storing the limit for determining status

public static final double STATUS_THRESHOLD=3.5;

//extra attributes

private int numberOfYards;

private int numberOfRushes;

public FootballPlayer() {

super();

numberOfYards = 0;

numberOfRushes = 0;

}

public FootballPlayer(int id, String playerName, String teamName,

String position, double salary, double commisionRate,

int numberOfYards, int numberOfRushes) {

/**

* passing data to super class

*/

super(id, playerName, teamName, position, salary, commisionRate);

this.numberOfRushes = numberOfRushes;

this.numberOfYards = numberOfYards;

}

public int getNumberOfYards() {

return numberOfYards;

}

public void setNumberOfYards(int numberOfYards) {

this.numberOfYards = numberOfYards;

}

public int getNumberOfRushes() {

return numberOfRushes;

}

public void setNumberOfRushes(int numberOfRushes) {

this.numberOfRushes = numberOfRushes;

}

/**

* calculates and return the stats

*/

public double calculateStatistics() {

if (numberOfRushes == 0) {

/**

* in case if number of rushes is 0, returning 0, or else it

* will cause an ArithmeticException when divided by zero

*/

return 0;

}

return (double) numberOfYards / numberOfRushes;

}

/**

* returns true of stats > limit , else false

*/

public boolean determineStatus() {

if (calculateStatistics() > STATUS_THRESHOLD) {

return true;

} else {

return false;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions