Question: [6 pts] Write the abstract class Subscriber as presented in the above UML. Write the constructor that takes as parameters all data fields. Assuming a
- [6 pts] Write the abstract class Subscriber as presented in the above UML.
- Write the constructor that takes as parameters all data fields.
- Assuming a subscriber has an id of 12345, name of John White, and monthly fees of 50, the toString method should return a String in the following format:
ID: 12345, Name: John White, Monthly Fees: $50.0
- [4 pts] Write the interface Discountable.
- Do not implement the class BasicSubscriber. The code is:
public class BasicSubscriber extends Subscriber{
private String joinDate;
public BasicSubscriber(int i, String n, double m, String j){
super(i,n,m);
joinDate = j;
}
@Override
public String toString(){
return super.toString()+", Join Date: "+ joinDate;
}
}
- [10 pts] Implement the class PremiumSubscriber.
The data field premiumYears contains for how many years the subscriber has been a premium subscriber.
- Write the constructor that takes as parameters all data fields.
- Implement the method feesAfterDiscount method of the Discountable interface. Only premium subscribers are eligible for a discount based on how many years they had premium subscription. Subscribers who have been premium for 3 years or less are eligible to a 20% discount; otherwise, they are eligible to a 40% discount.
- Assuming a subscriber has an id of 12345, name of John White, monthly fees of 50, and 4 premium years, the toString method should return a String in the following format:
ID: 12345, Name: John White, Monthly Fees: $50.0, Premium Years: 4, Monthly Fees after discount: $30.0
- [20 pts] Implement the class SpotifyPage that represents an artists Spotify Page.
Each page has a title, a set of subscribers, and their number.
- Write the constructor that takes as parameters the title of the page and the maximum number of subscribers that it can hold.
- Write the addSubscriber method that adds a subscriber to the page if it is not already full. If it is full, an error message should be displayed.
- Write the subscriberById method that looks for a subscriber by its id. If found, the method should return the subscriber object, otherwise, it returns null.
- Write the nbOfPremiumSubscribers method that returns the number of premium subscribers of the page.
- Write the totalMonthlyIncome method that calculates and returns the total monthly income generated by the page by summing the subscribers monthly fees.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
