Here's the problem:
Problem A: Lane Basketball team. Objectives: Creating classes, passing parameters to objects from a driver program.
Write a class for the Lane Basketball team named Athlete which has the following attributes: name, position, height in feet and inches. Write appropriate mutator (set) methods which change each of the attribute values, and accessor (get) methods which return the attribute values. Create a driver program which creates four athlete objects, stores the following values in each, and then displays the values for each athlete.
Height
Name Position Feet Inches
A. Samuels Guard 6 3
C. Truman Forward 5 11
S. Hendricks Point Guard 6 1
N. Anderson Center 6 5
... I've written the Athlete class but I'm not entirely sure how it's supposed compile together.
/**
* Athlete Class
*/
public class Athlete
{
// Fields
private String PlayerName; //player name
private String PlayerPosition; //player position
private double PlayerHeight; //height of player
public Athlete(String name, String pos, double hgt)
{
PlayerName = name;
PlayerPosition = pos;
PlayerHeight = hgt;
}
public void setPlayerName(String name)
{
PlayerName = name;
}
public void setPlayerPosition(String pos)
{
PlayerPosition = pos;
}
public void setPlayerHeight(double hgt)
{
PlayerHeight = hgt;
}
public String getPlayerName()
{
return PlayerName;
}
public String getPlayerPosition()
{
return PlayerPosition;
}
public double getPlayerHeight()
{
return PlayerHeight;
}
}
Then I have to create a driver program. This is where it gets sticky. Am I supposed to input the attributes into the driver program? How do I go about doing this? So far I'm up to here.
public class AthleteTest
{
public static void main(String[] args)
{
String testName;
String testPosition;
double testHeight;
Athlete display1 = new Athlete(A. Samuels, Guard, 6.3);
Athlete display2 = new Athlete(C. Truman, Forward, 5.11);
Athlete display3 = new Athlete(S. Hendricks, Point Guard, 6.1);
Athlete display4 = new Athlete(N. Anderson, Center, 6.5);
I have a feeling I'm like TOTALLY off.
Thanks in advance for your help.