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
icon
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.
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());
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Random Class and its operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education