Ask Question
20 October, 13:27

Create an application named TestSoccerPlayer that instantiates and displays a SoccerPlayer object. The SoccerPlayer class contains the following properties: Name - The player's name (a string) JerseyNum - The player's jersey number (an integer) Goals - Number of goals scored (an integer) Assists - Number of assists (an integer)

+1
Answers (1)
  1. 20 October, 15:44
    0
    public class TestSoccerPlayer {

    public static void main (String[] args) {

    SoccerPlayer playerOne = new SoccerPlayer ("Rinco",9,16,22);

    System. out. println ("The player of the season is "+playerOne. getName () + " His Jessey Number is "+playerOne. getJerseyNum ()

    +" In the 2019/2020 season he scored and total of "+playerOne. getGoalsScored () + " and "+

    playerOne. getAssists () + " Asists");

    }

    }

    See the SoccerPlayer class with the feilds and methods (constructor, getter and setters) in the explanation section

    Explanation:

    public class SoccerPlayer {

    private String name;

    private int jerseyNum;

    private int goalsScored;

    private int assists;

    public SoccerPlayer (String name, int jerseyNum, int goalsScored, int assists) {

    this. name = name;

    this. jerseyNum = jerseyNum;

    this. goalsScored = goalsScored;

    this. assists = assists;

    }

    public String getName () {

    return name;

    }

    public void setName (String name) {

    this. name = name;

    }

    public int getJerseyNum () {

    return jerseyNum;

    }

    public void setJerseyNum (int jerseyNum) {

    this. jerseyNum = jerseyNum;

    }

    public int getGoalsScored () {

    return goalsScored;

    }

    public void setGoalsScored (int goalsScored) {

    this. goalsScored = goalsScored;

    }

    public int getAssists () {

    return assists;

    }

    public void setAssists (int assists) {

    this. assists = assists;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create an application named TestSoccerPlayer that instantiates and displays a SoccerPlayer object. The SoccerPlayer class contains the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers