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.
- Add a VideoGame class and all the necessary code so VideoGame inherits from the Game class.
- Add a private variable to the VideoGame class called totalPoints, and initialize totalPoints to 0.
- Add a getter method called getScore() to get the totalPoints variable.
- Add a method called addToScore(points) that adds the points to totalPoints.
- Instantiate a new VideoGame object with the title "Pac-Man". Call the appropriate methods to:
- Start playing the game.
- Show the score (should be 0).
- Add 20 points.
- Add 50 points.
- Show the score (should be 70).
- Stop playing the game.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
