Given: public class Team { private Player[] players; private int squadSize; public Team(Player[] players) { this.players = players; this.size = players.length; } public Team() { this.players = new Player[4]; this.size = 0; } } How would I go about creating the given methods? (Rating variable in supplied java file.)
Given: public class Team { private Player[] players; private int squadSize; public Team(Player[] players) { this.players = players; this.size = players.length; } public Team() { this.players = new Player[4]; this.size = 0; } } How would I go about creating the given methods? (Rating variable in supplied java file.)
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Given:
public class Team {
private Player[] players;
private int squadSize;
public Team(Player[] players) {
this.players = players;
this.size = players.length;
}
public Team() {
this.players = new Player[4];
this.size = 0;
}
}
How would I go about creating the given methods? (Rating variable in supplied java file.)
![xferMarket
a) Given an index represented by an int, sell the player in that slot to the transfer
market and print "Transferred: {player}" on its own line. Remove the player from
the players array and return the player that was transferred.
b) If the index is invalid or there is not a player at that index, print "There was no
player to transfer!" on its own line and return null.
c) Update size if a player was removed.
displayPlayers.
a) Given an int representing a player's Rating, display all players with a
rating greater than the value passed in by printing each player on its own
Line.
train Players
a) Train all the players that are trainable by adding a random integer in the range
[0,5] to their current Rating
b) Print each Player that was trained in the following format on its own line:
"Trained to {newRating}: {player}".
1. *player refers to the player's information before they are trained (i.e., the
player should be printed with the old skill rating).
c) If no players were trained, print "There were no players to train.❞ on its
own line.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F295c436f-1881-4143-81a2-89f6f40be87f%2Fb97f7f94-e9d7-4ab8-b971-d38e57e41032%2Fipe2d2v_processed.png&w=3840&q=75)
Transcribed Image Text:xferMarket
a) Given an index represented by an int, sell the player in that slot to the transfer
market and print "Transferred: {player}" on its own line. Remove the player from
the players array and return the player that was transferred.
b) If the index is invalid or there is not a player at that index, print "There was no
player to transfer!" on its own line and return null.
c) Update size if a player was removed.
displayPlayers.
a) Given an int representing a player's Rating, display all players with a
rating greater than the value passed in by printing each player on its own
Line.
train Players
a) Train all the players that are trainable by adding a random integer in the range
[0,5] to their current Rating
b) Print each Player that was trained in the following format on its own line:
"Trained to {newRating}: {player}".
1. *player refers to the player's information before they are trained (i.e., the
player should be printed with the old skill rating).
c) If no players were trained, print "There were no players to train.❞ on its
own line.
![public class Data {
private String Name;
private int Endurance;
private Position [] positions;
private int Rating;
}
}
public Data (String Name, int Endurance, Position [] positions, int Rating) {
this.Name = Name;
}
public Data (String Name, Position [] positons) {
this.Name = Name;
this.Endurance = Endurance;
this.positions = positions;
this.Rating = Rating;
}
public Data (){
this.Endurance = 50;
this.positions
this.Rating
=
}
=
70;
}
positons;
this.Name = "Botman";
}
public boolean trainAbility() {
return skillRating >= 50 && skillRating <= 89;
this. Endurance = 50;
this.positions = new Position[]{Position.defender};
this.Rating = 70;
public Position maxPosition() {
return positions [0];
}
public Position[] getPositions() {
return positions;
}
public boolean other Positions (Position position ToCheck) {
for (Position position : getPositions()) {
if (position == positionToCheck) {
return true;
}
}
return false;
public String toString() {
return String.format("<%s,%d,%s,%d,%b>", Name, Endurance, maxPosition(), Rating, trainAbility());](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F295c436f-1881-4143-81a2-89f6f40be87f%2Fb97f7f94-e9d7-4ab8-b971-d38e57e41032%2Fs8pbdi_processed.png&w=3840&q=75)
Transcribed Image Text:public class Data {
private String Name;
private int Endurance;
private Position [] positions;
private int Rating;
}
}
public Data (String Name, int Endurance, Position [] positions, int Rating) {
this.Name = Name;
}
public Data (String Name, Position [] positons) {
this.Name = Name;
this.Endurance = Endurance;
this.positions = positions;
this.Rating = Rating;
}
public Data (){
this.Endurance = 50;
this.positions
this.Rating
=
}
=
70;
}
positons;
this.Name = "Botman";
}
public boolean trainAbility() {
return skillRating >= 50 && skillRating <= 89;
this. Endurance = 50;
this.positions = new Position[]{Position.defender};
this.Rating = 70;
public Position maxPosition() {
return positions [0];
}
public Position[] getPositions() {
return positions;
}
public boolean other Positions (Position position ToCheck) {
for (Position position : getPositions()) {
if (position == positionToCheck) {
return true;
}
}
return false;
public String toString() {
return String.format("<%s,%d,%s,%d,%b>", Name, Endurance, maxPosition(), Rating, trainAbility());
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education