Search code examples
javaclassprogram-entry-point

modify score for object to get the value 2400 and display it


Hello I'm new to java , could u plz help me with this, I want to create an instance player in game class and modify score to get the value 2400 and display it


Solution

  • Your constructor is wrong. It shouldn't be score=0, it should be this.score=score

    And it should also be this.nom = nom

    Then you can just do

    Player player = new Player("nn", 2400)

    System.out.println(player.toString())