Question: aurgent please answer these are for question one i posted too D. [10 pts] Implement the class PremiumSubscriber. The data field premium Years contains for
aurgent please answer
these are for question one i posted too
D. [10 pts] Implement the class PremiumSubscriber. The data field premium Years contains for how many years the subscriber has been a premium subscriber. a) Write the constructor that takes as parameters all data fields. b) 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. c) 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 E. [20 pts] Implement the class SpotifyPage that represents an artist's Spotify Page. Each page has a title, a set of subscribers, and their number. a) Write the constructor that takes as parameters the title of the page and the maximum number of subscribers that it can hold. b) 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. c) Write the subscriberById method that looks for a subscriber by its id. If found, the m Vd return the subscriber object, otherwise, it returns null. 3/5 d) Write the nbOf PremiumSubscribers method that returns the number of premium subs page. e) Write the totalMonthlyIncome method that calculates and returns the total monthly income generated by the page by summing the subscribers' monthly fees. Question 2 [20 points] Implement the driver class (application) as follows: a) Create a SpotifyPage of your choice and give it a capacity of 10. Add one premium subscriber and two basic subscribers of your choice to the page created. b) Write a code that asks the user to enter the id of a subscriber and print its name on the screen if found, or display an error message otherwise. c) Write a code that displays the information of the basic subscribers in the page. d) Write a code that displays the number of subscribers who have been premium for more than 5 years
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
