Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java /** * Abstract Post class abstract class Post { /** * Number of likes on this post */ private int numLikes; /** *

image text in transcribedIn 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 system

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Domain Transfer Learning With 3q Data Processing

Authors: Ahmed Atif Hussain

1st Edition

B0CQS1NSHF, 979-8869061805

More Books

Students also viewed these Databases questions