Question

For this assignment, you'll create a Player class that captures information about players on a sports...

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:

  • Named Player
  • Is public to allow access from other object and assemblies
  • Has a constructor that accepts the following parameters:
    • name as a string
    • number as an integer
    • position as a string
  • Exposes the following parameters (set the matching values in the constructor)
    • Name as string
    • Number as integer
    • Position as string
    • Points as integer
  • Has a Score method that accepts a integer value for points. When called, increase the Points value for the player by the value passed in.
  • Has a DisplaySummary method that prints out a summary 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

Homework Answers

Answer #1
//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);
                
        }
        
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
Suppose you have already written the class for a Bowler. The Bowler class has two fields,...
Suppose you have already written the class for a Bowler. The Bowler class has two fields, a full name and a high score. Write the main() method to create two instances of this Bowler class. Get the input from the user and send the name and high score values to the constructor method of the Bowler class.
Create a simple Java class for a Month object with the following requirements:  This program...
Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...
Write the following problem in Java Create a class Dog, add name, breed, age, color as...
Write the following problem in Java Create a class Dog, add name, breed, age, color as the attributes. You need to choose the right types for those attributes. Create a constructor that requires no arguments. In this constructor, initialize name, breed, age, and color as you wish. Define a getter and a setter for each attribute. Define a method toString to return a String type, the returned string should have this information: “Hi, my name is Lucky. I am a...
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
Java For this assignment you need to create at least 5 classes. 1.Create a vehicle class...
Java For this assignment you need to create at least 5 classes. 1.Create a vehicle class ( super class) 2,3. Create two sub classes ( car, bus , truck train or any) for vehicle class 4 Create a subclass (sportscar or schoolbus or Goodstrain or any) for car or bus You need to use the following atleast for one class. Use a protected variable Add constructor for superclass and subclass Override a method which displays a description about the vehicle...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor public Bicycle( String name, int license ) { ownerName = name;    licenseNumber = license; } // Returns the name of the bicycle's owner public String getOwnerName( ) { return ownerName; } // Assigns the name of the bicycle's owner public void setOwnerName( String name ) { ownerName = name; } // Returns the license number of the bicycle public int getLicenseNumber( ) {...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent. E.g. • in the term 4X2, the coefficient is 4 and the exponent 2 • in -6X8, the coefficient is -6 and the exponent 8 Your class will have a constructor that creates a Term object with a coefficient and exponent passed as...
loanCreator.java: /* * Use constants when necessary, define with proper scope * * Create Person class...
loanCreator.java: /* * Use constants when necessary, define with proper scope * * Create Person class with data fields of firstName and lastName these fields can not change. * * Create Loan class with data fields of Person, loan Amount, term and interest rate * If term is not past in then default value is 36 * If interest is not past in then default value is 5.0 * * In Loan class create method to construct output String *...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT