Ask Question
27 November, 14:46

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)

+3
Answers (1)
  1. 27 November, 15:07
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers