Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File of runner Ultimate.java import java.util.ArrayList; import java.util.Scanner; public class runner_Ultimate{ public static void main(String[] args){ ArrayList players = new ArrayList (); ArrayList coaches =

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

File of runner Ultimate.java

import java.util.ArrayList; import java.util.Scanner;

public class runner_Ultimate{

public static void main(String[] args){ ArrayList players = new ArrayList(); ArrayList coaches = new ArrayList(); Scanner scan = new Scanner(System.in); String ins = ""; while(!ins.equals("q")){ System.out.println(" What do you want to do? p - make a person t - make a team from the current player/coach lists q - quit"); ins = scan.nextLine().toLowerCase(); if(ins.equals("p")){ Person p; System.out.println(" Which class do you want to use? p - Person u - UltimatePlayer c - Captain o - Coach"); String cls = scan.nextLine().toLowerCase(); System.out.println("First name?"); String fn = scan.nextLine(); System.out.println("Last name?"); String ln = scan.nextLine(); if(cls.equals("u")||cls.equals("c")){ System.out.println("Position?"); String ps = scan.nextLine(); if(cls.equals("c")){ System.out.println("Offensive coach? (t/f)"); boolean tp = scan.nextLine().toLowerCase().equals("t"); p = new Captain(fn, ln, ps, tp); } else p = new UltimatePlayer(fn, ln, ps); players.add((UltimatePlayer)p); System.out.println(" " + fn + " " + ln + " was added to the players list."); } else if(cls.equals("o")){ System.out.println("Role?"); String rl = scan.nextLine(); p = new Coach(fn, ln, rl); coaches.add((Coach)p); System.out.println(" " + fn + " " + ln + " was added to the coaches list."); } else{ p = new Person(fn, ln); System.out.println(" Sorry, only UltimatePlayers, Captains and Coaches can be added to the team."); } System.out.println(" " + p); System.out.println(" Type \"t\" for " + fn + " to throw a disc."); if(scan.nextLine().toLowerCase().equals("t")){ System.out.println("Enter power level between 1 and 10."); System.out.println(fn + " threw the disc " + p.throwDisc(scan.nextInt()) + " yards."); scan.nextLine(); } } else if(ins.equals("t")){ UltimateTeam t = new UltimateTeam(players, coaches); System.out.println(" Your team is ready! "); while(!ins.equals("q")){ System.out.println(" What do you want to do? c - see the cutters h - see handlers t = see the whole team q - quit"); ins = scan.nextLine().toLowerCase(); if(ins.equals("h")) System.out.println(" " + t.getHandlers()); else if(ins.equals("c")) System.out.println(" " + t.getCutters()); else if(ins.equals("t")) System.out.println(" " + t + " "); } } } } }

File of Person.java

//blank

File of Coach.java

//blank

File of UltimateTeam.java

// Don't forget, you will need to import the ArrayList class to implement the UltimateTeam class

File of Captain.java

//blank

File of UltimatePlayer.java

//blank

Getting Started For this assignment, you will create a hierarchy of five classes to describe various elements of an ultimate frisbeec team. Ultimate frisbee is a non- contact sport with players at a position of "cutter" or "handler". A team usually also has a head coach and possibly one or more assistant coaches. An ultimate team has seven players on the field, with four players at the position of cutter and three at the position of handler. Check out the below video to learn more about this great sport! The classes you will write are: Person, Ultimate Player, Captain, Coach, and Ultimate Team. Detailed below are the requirements for the variables and methods of each class. You may need to add a few additional variables and/or methods; figuring out what is needed is part of your task for this assignment. Person Variables String firstName - Holds the person's first name. String lastName - Holds the person's last name. Methods Person(String firstName, String lastName) - Constructor that takes in String parameters representing the first and last names. int throwDisc(int pow) - returns the distance in yards a frisbee is thrown by the person. This is calculated by multiplying the power of the throw by 2. The power is given by the parameter pow, with a minimum value of 1 if pow is below this, and a maximum value of 10 if pow is above this. String toString() - Returns a String with the following format: lastName, firstName Coach extends Person Variables String role - Role of coach on the team. This is a flexible description; there are no required values for this variable. For example, "Head Coach" or "Assistant Coach". Methods Coach(String firstName, String lastName, String role) - The first and last names should be set by calling the constructor of the parent class. String toString() - Returns a two-line String with Coach info formatted as follows: Wagner, Rebecca Role: Head Coach Note: there are three spaces before "Role: ...". Ultimate Player extends Person Variables int jerseyNumber - Using a static variable to keep track of ultimate player jersey numbers, every player should be assigned a unique value for their own jersey number. String position - Represents a player's position. Possible values are "handler" and "cutter". Methods UltimatePlayer(String firstName, String lastName, String position) - Constructor that accepts the first name, last name and the position of a player. The first and last names should be set by calling the constructor of the parent class. Position should be set to "handler" if the input string is not "handler" or "cutter". The Ultimate Player constructor also sets the jersey number to the next available positive integer. The first Ultimate Player created should have a jersey number of 1, the second will have a jersey number of 2, third of 3, etc. String getPosition() - Returns the Ultimate Player's position. int throwDisc(int pow) - returns the distance in yards a frisbee is thrown by the player. This is calculated by multiplying the power of the throw by 4. The power is given by the parameter pow, with a minimum value of 1 if pow is below this, and a maximum value of 10 if pow is above this. String toString() - Returns a three-line String with Ultimate Player information formatted as follows: Smith, Mary Jersey #: 1 Position: cutter Note: there are three spaces before "Jersey #: .." and "Position:...". Captain extends UltimatePlayer Variables boolean type - Captains on an Ultimate team are usually responsible for either offense or defense. This variable is a boolean representing the type of captain, true for offense, false for defense. Methods Captain(String firstName, String lastName, String position, boolean type) - The first and last names and the position should be set by calling the constructor of the parent class. int throwDisc(int pow) - returns the distance in yards a frisbee is thrown by the person. This is calculated by multiplying the power of the throw by 5. The power is given by the parameter pow, with a minimum value of 1 if pow is below this, and a maximum value of 10 if pow is above this. String toString() - Returns a four-line String with Captain info formatted as follows: Lee, Sarah Jersey #: 2 Position: handler Captain: offense Note: there are three spaces before "Jersey #: ...", "Position:..." and "Captain: ...". Ultimate Team Variables ArrayList players - The list of ultimate players on the team. ArrayList coaches - A list of the team's coaches. Methods ultimateTeam(ArrayList players, ArrayList coaches) - A constructor that specifies the coaches and players of the team. String getCutters() - Returns a String listing all the Ultimate Teams's Ultimate Players that have the position of "cutter" in the order they appear in the players list. Each String can be produced using the toString method, and should be followed by a line break. String getHandlers() - Returns a String listing all the Ultimate Teams's Ultimate Players that have the position of "handler" in the order they appear in the players list. Each String can be produced using the toString method, and should be followed by a line break. . String toString() - Returns a multiline String listing the Coaches and Ultimate Players on the Ultimate Team. The String is formatted as shown in this example: COACHES Mathour, Maryam Role: Head Coach Van Loben Sels, Soren Role: Assistant Coach PLAYERS Trong, Sammy Jersey #: 1 Position: handler Patel, Jayant Jersey #: 2 Position: handler Ozaeta, Myra Jersey #: 3 Position: cutter Holbrook, Lisa Jersey #: 4 Position: cutter Kvale, Lisbeth Jersey #: 5 Position: cutter Henry, Malik Jersey #: 6 Position: handler Captain: offense Pak, Joseph Jersey #: 7 Position: cutter Captain: defense The coaches listing is made up of all items from the coaches ArrayList in order. The players listing is made up of all items from the players ArrayList in order. Final Notes Remember, all variables should have an access level of private and all required methods should have an access level of public. Wherever possible, the child class should use a call to the parent's toString and/or constructor methods. Use the runner class main method to test all your classes, and please don't add a main method to any of the other classes or your code may not be marked correctly. When debugging your code it makes sense to debug the classes higher in the hierarchy first: for example the methods in the Captain class may not work correctly until the methods in its parent class (UltimatePlayer) work properly. The last thing to debug is the ultimate Team class, as this relies on methods from all the other classes created. Milestones As you work on this assignment, you can use the milestones below to inform your development process: Milestone 1: Write the Person class, then write the Coach class extending the Person class with all methods implemented. Milestone 2: Write the Ultimate Player class extending the Person class with all methods implemented. Milestone 3: Write the Captain class extending the Ultimate Player class with all methods implemented. Milestone 4: Write the Ultimate Team class and implement all the methods it contains. KY Files STATUS O NOT SUBMITTED SAVE SUBMIT INSTRUCTIONS RUN CODE GRADING HISTORY runner Ultimate.java Person.java Coach.java The classes you will write are: Person, Ultimate Player, Captain, Coach, and Ultimate Team. Detailed below are the requirements for the variables and methods of each class. You may need to add a few additional variables and/or methods; figuring out what is needed is part of your task for this assignment. UltimateTeam.java Captain.java UltimatePlayer.java Person 1- import java.util.ArrayList; 2 import java.util.Scanner; 3 4- public class runner_Ultimate 5 6- public static void main(String[] args) { 7 ArrayList players = new ArrayList(); 8 ArrayList coaches = new ArrayList(); 9 Scanner scan = new Scanner(System.in); 10 String ins = ""; 11 - while(!ins.equals("q")) { 12 System.out.println(" What do you want to do? p - make a person t - make a team from the current player/coach lists g - quit"); 13 ins = scan.nextLine().toLowerCase(); 14 if(ins.equals("")) { 15 Person p; 16 System.out.println(" Which class do you want to use? p - Person u - UltimatePlayerinc - Captain o - Coach"); 17 String cls = scan.nextLine().toLowerCase(); 18 System.out.println("First name?"); 19 String fn = scan.nextLine(); 20 System.out.println("Last name?"); 21 String in = scan.nextLine(); 22 if (cls.equals("u")||cis.equals("")) { 23 System.out.println("Position?"); 24 String ps - scan.nextLine(); 25 if (cls.equals("")) { 26 System.out.println("Offensive coach? (t/f)"); 27 boolean tp = scan.nextLine().toLowerCase().equals("t"); 28 p = new Captain(fn, in, ps, tp); 29 } 30 else 31 p = new UltimatePlayer(fn, In, ps); 32 players.add((UltimatePlayer)p); Variables String firstName - Holds the person's first name. String lastName - Holds the person's last name. Methods Person(String firstName, String lastName) - Constructor that takes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago