Question: The JavaScript code defines a Game class and 2 methods. Add a VideoGame class and all the necessary code so VideoGame inherits from the Game

The JavaScript code defines a Game class and 2 methods.

  1. Add a VideoGame class and all the necessary code so VideoGame inherits from the Game class.
  2. Add a private variable to the VideoGame class called totalPoints, and initialize totalPoints to 0.
  3. Add a getter method called getScore() to get the totalPoints variable.
  4. Add a method called addToScore(points) that adds the points to totalPoints.
  5. Instantiate a new VideoGame object with the title "Pac-Man". Call the appropriate methods to:
    1. Start playing the game.
    2. Show the score (should be 0).
    3. Add 20 points.
    4. Add 50 points.
    5. Show the score (should be 70).
    6. Stop playing the game.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!