Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a BaseballPlayer class that will store information about a baseball player

ID: 3902827 • Letter: W

Question

Write a BaseballPlayer class that will store information about a baseball player. The class should store the following information: name, jersey number, and age. The class should contain the following information:

// Only constructor in the class

public BaseballPlayer(String name, int jerseyNumber, int age)

// Should return the following:

// __________(name) is ____ (age) years old and wears # ____(jersey number)

// For example, Derek Jeter is 35 years old and wears #2

public String toString()

// Include getters and setters for all the fields

Write in Java and at a simple level

Explanation / Answer

public class BaseballPlayer { private String name; private int jerseyNumber; private int age; public BaseballPlayer() { } public BaseballPlayer(String name, int jerseyNumber, int age) { this.name = name; this.jerseyNumber = jerseyNumber; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getJerseyNumber() { return jerseyNumber; } public void setJerseyNumber(int jerseyNumber) { this.jerseyNumber = jerseyNumber; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "BaseballPlayer{" + "name='" + name + ''' + ", jerseyNumber=" + jerseyNumber + ", age=" + age + '}'; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote