Question

In: Computer Science

Project name: Practical1LastFirst You are being asked to create a program related to tracking players on...

Project name: Practical1LastFirst

You are being asked to create a program related to tracking players on a ringette team. It is important to create as per the requirements document. The details of the RingettePlayer class are provided in the following class diagram.

RingettePlayer

-firstName: String

-lastName: String

-allergies: String

-jerseyNumber: int

-birthYear: int

Constructors

+RingettePlayer()    

+RingettePlayer(String, String)

+RingettePlayer(int)

+RingettePlayer(String, String, String, int)   

+getters/setters for all

+getInformation():void

+display():void

+toString(): String

Default Values for Attributes

When values are not provided for attributes, the following are the values that should be set for the attributes. Note that these are the only attributes that are to be in the class.

  • firstName and lastName default: “Unknown”
  • allergies default: “”
    • The default for allergies is an empty string
  • jerseyNumber and birthYear: 0

Constructor Details

Create four constructors in the RingettePlayer class based on the following requirements.

  • Default no-parameter constructor
    • Create a default no-parameter constructor for the RingettePlayer which sets attributes to their default values.
  • RingettePlayer(String, String)   
    • First and last names passed as parameters and set.
    • the jersey number, birthYear and allergies set to their default values
  • RingettePlayer(int)
    • jerseyNumber passed as a parameter
    • Other attributes are set to their default values
  • RingettePlayer(String, String, String int, int)
    • Values for all attributes are passed in as parameters and used to set object attribute values.

Controller Class Functionality

In the main method create three object based on the following specifications. You can use your own name for the variable name.

  • The first object created should be created using the constructor that accepts two Strings to set the first and last name in the instance (example: “Brielle”, “Jones”). The user does not have to be prompted for these values. They are to be set as hard coded values.
  • The second object created should be created with the default constructor and the setters used to set her first name (“Marley”), last name (“Stephens”), allergies (“Dust”) and jersey number (9). The user does not have to be prompted for these values. They are to be set as hard coded values.
  • The third object should be created using the default constructor. The values for this object are to be obtained from the user by using the getInformation() method. The output below shows an example with user entered data.
    • Note that when the program runs, they would be prompted for the values of this object as the first interaction with the user.

Additional Requirements

  • After creating each of these objects in the main method, have the program display their values to the console.

Ringette Players

Name: Brielle Jones Jersey Number: 0 Allergies: Birth Year: 0

Name: Marley Stephens Jersey Number: 9 Allergies: Dust Birth Year: 0

Name: Sarah Miles Jersey Number: 15 Allergies: Nuts Birth Year: 2009

  • After showing each of the players above have an additional output which shows the allergies only.

Allergies for all players:

Dust Nuts

Solutions

Expert Solution

please find the below classes for the solution:

package practical1LastFirst;

import java.util.Scanner;

public class RingettePlayer {
   private String firstName;
   private String lastName;
   private String allergies;
   private int jerseyNumber;
   private int birthYear;

   public RingettePlayer() {
       this.firstName = "Unknown";
       this.lastName = "Unknown";
       this.allergies = "";
       this.birthYear = 0;
       this.jerseyNumber = 0;

   }

   public RingettePlayer(String firstName, String lastName) {
       this.firstName = firstName;
       this.lastName = lastName;
       this.allergies = "";
       this.birthYear = 0;
       this.jerseyNumber = 0;

   }

   public RingettePlayer(int jerseyNumber) {
       this.firstName = "Unknown";
       this.lastName = "Unknown";
       this.allergies = "";
       this.birthYear = jerseyNumber;
       this.jerseyNumber = 0;

   }

   public RingettePlayer(String firstName, String lastName, String allergies, int jerseyNumber, int birthYear) {
       this.firstName = firstName;
       this.lastName = lastName;
       this.allergies = allergies;
       this.jerseyNumber = jerseyNumber;
       this.birthYear = birthYear;
   }

   public void getInformation() {
       Scanner in = new Scanner(System.in);
       System.out.print("Enter your first name: ");
       this.firstName = in.next();
       System.out.print("Enter your last name: ");
       this.lastName = in.next();
       System.out.print("Enter your allergies: ");
       this.allergies = in.next();
       System.out.print("Enter your birth Year: ");
       this.birthYear = in.nextInt();
       System.out.print("Enter your jersey Number: ");
       this.jerseyNumber = in.nextInt();
       in.close();

   }

   public void display() {
       System.out.println(toString());
   }

   public String toString() {
       return "Name: " + firstName + " " + lastName + " Jersey Number: " + jerseyNumber + " Allergies: " + allergies
               + " Birth Year: " + birthYear;

   }

   public String getFirstName() {
       return firstName;
   }

   public void setFirstName(String firstName) {
       this.firstName = firstName;
   }

   public String getLastName() {
       return lastName;
   }

   public void setLastName(String lastName) {
       this.lastName = lastName;
   }

   public String getAllergies() {
       return allergies;
   }

   public void setAllergies(String allergies) {
       this.allergies = allergies;
   }

   public int getJerseyNumber() {
       return jerseyNumber;
   }

   public void setJerseyNumber(int jerseyNumber) {
       this.jerseyNumber = jerseyNumber;
   }

   public int getBirthYear() {
       return birthYear;
   }

   public void setBirthYear(int birthYear) {
       this.birthYear = birthYear;
   }
}

package practical1LastFirst;

public class Controller {

   public static void main(String[] args) {
      
       RingettePlayer ringettePlayerFirst=new RingettePlayer("Brielle", "Jones");
       RingettePlayer ringettePlayersecond=new RingettePlayer();
       ringettePlayersecond.setFirstName("Marley");
       ringettePlayersecond.setLastName("Stephens");
       ringettePlayersecond.setAllergies("Dust");
       ringettePlayersecond.setJerseyNumber(9);
       RingettePlayer ringettePlayerthird=new RingettePlayer();
       ringettePlayerthird.getInformation();
       System.out.println("Ringette Players");
       ringettePlayerFirst.display();
       ringettePlayersecond.display();
       ringettePlayerthird.display();
       System.out.println("Allergies for all players:");
       System.out.println(ringettePlayerFirst.getAllergies()+" "+ringettePlayersecond.getAllergies()+" "+ringettePlayerthird.getAllergies() );
   }

}


Related Solutions

You are an IT manager for a small business. You are being asked to create a...
You are an IT manager for a small business. You are being asked to create a network security plan both for internal IT workers and for the company in general. You are to put together a network security plan that addresses each of the following components : Explain the use of virtual private networks (VPNs) and their security benefits and drawbacks. Create a standard procedure for adding new users to a network. Create a summary of a network plan, including...
You must create a project in intelliJ that you will name midterm_<yourLastname>. Inside the project you...
You must create a project in intelliJ that you will name midterm_<yourLastname>. Inside the project you must implement the following packages and classes as they appear in the following description: A public class called Square in a package it200.midterm.shapes. The class contains the following: An int field called side, that stores the size of each side of the square (in terms of number of characters) A char field called symbol, which stores a character as the symbol we use to...
Imagine that you are asked to create a dissemination plan for a health promotion program. You...
Imagine that you are asked to create a dissemination plan for a health promotion program. You have just learned that most of the stakeholders that you planned to present to are leaving the country in two weeks and will be gone for the next six months, so you must present your findings to them before they leave. Originally, you had three months to prepare your dissemination plan. Do you think that the plan should be disseminated as it would be...
If you were a hospital CEO being asked to redirect IT resources for this project, what...
If you were a hospital CEO being asked to redirect IT resources for this project, what would you want in return from the agency to ensure that this system provided value to your organization and clinicians?
Create a project for this assignment. You can name it assignment02 if you wish. Download the...
Create a project for this assignment. You can name it assignment02 if you wish. Download the database file pizza-190807A.sqlite into the top level of the project. Create the pizza_services.py module first and put in the code given in the assignment. Using this code ensures that you can use the services in a similar way to the example. The assignment suggests adding a method customer to the class. This will return a list of rows from the customer table in the...
For this project, you will create a program in C that will test the user’s proficiency...
For this project, you will create a program in C that will test the user’s proficiency at solving different types of math problems.   The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The user will be allowed 3 tries at...
Create a C# console application (do not create a .NET CORE project) and name the project....
Create a C# console application (do not create a .NET CORE project) and name the project. Generate two random integers, each between 1 and 50, that you will be adding together to test the user's ability to perform the addition operator. Display the numbers in the console, such as:             7 + 22 = ? Once the user provides their answer, check to see if it is correct and if not, tell them sorry, please try again. If their answer...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TuitionIncrease. The college charges a full-time student $12,000 in tuition per semester. It has been announced that there will be a tuition increase by 5% each year for the next 7 years. Your application should display the projected semester tuition amount for the next 7 years in the console window in the following format:             The tuition after year 1 will be $12,600. Note:...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TimeToBurn. Running on a particular treadmill, you burn 3.9 calories per minute. Ask the user how many calories they wish to burn in this workout session (this is their goal). Once they tell you, output on the console after each minute, how many calories they have burned (e.g. After 1 minute, you have burned 3.9 calories). Keep outputting the total amount of calories they...
You have been asked to create a program that builds a tower base on the number...
You have been asked to create a program that builds a tower base on the number of items given as input. When the only 1 item is given you create no tower you just place the item on top of the stand. When 2 items are given you build the base of the tower with one foot to the right and one foot to the left. The feet will be in the ground and support the tower. For every additional...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT