Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In java /** * Abstract Post class abstract class Post { /** * Number of likes on this post */ private int numLikes; /** *
In java
/** * Abstract Post class abstract class Post { /** * Number of likes on this post */ private int numLikes; /** * Add a like to this post */ public void addLike() { this.numLikes += 1; /** * Get number of likes on this post * @return Number of likes on this post public int getNumLikes() { return this.numLikes; /** * Get the popularity of this post * Defines "popularity" as number of likes * @return the popularity of this post */ public int get Popularity() { return this.numLikes; TASK: Create a class called Video Post that extends the Post abstract class and has the following properties: It should have a private instance variable of type int called numViews to keep track of the number of video views It must have a public no-parameter constructor that initializes its instance variables to 0 (the default one provided implicitly by Java is fine) It must have a public instance method called getNumViews that returns the number of views It must have a public void instance method called addView that increments the number of views It must override the get Popularity method to instead define "popularity" as number of views NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading systemStep 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