For this assignment, you'll create a Player class that captures information about players on a sports team. We'll keep it generic for this assignment, but taking what you learn with this assignment, you could create a class tailored to your favorite sport. Then, imagine using such a class to track the stats during a game.
Player Class Requirements
Your class should bet set up as follows:
#Number Name at Position has Points points
#11 John Doe at Center has 12 points
Main Program Logic
I'll only be testing the player class for this assignment, so you can put whatever you want in your main method. This could include asking the user for the name, number, and position; creating the player object; calling the Score method to add points; and then calling the DisplaySummary method to print the final output. Has to be in C# Visual studio, take user input for name number position and points
//only Player class has been implemented as it is mentioned that only that will be tested. We can put a menu driven program to create an array of player for our team with different parameters using the constructor
public class Player{
private String name;
private int number;
private String position;
private int points;
public Player(String name,int number,String position,int points){
this.name = name;
this.number = number;
this.position = position;
this.points = points;
}
//implementing getter methods to access private variables
public String getName(){
return name;
}
public int getNumber(){
return number;
}
public String getPosition(){
return position;
}
public int getPoints(){
return points;
}
public void Score(int score){
points += score;
}
public void DisplaySummary(){
Console.WriteLine("#"+number+" "+name+" at "+position + " has Points " + points);
}
}
Get Answers For Free
Most questions answered within 1 hours.