Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started