Create an interface RateConstants that includes a constant value for the subscription rate that is $15.5. Create a class NewspaperSubsciption that implements the RateConstants interface. A...


Create an interface RateConstants that includes a constant value for the subscription rate that is $15.5.


Create a class NewspaperSubsciption that implements the RateConstants interface. A NewspaperSubscription class includes fields for the subscriber’s name and rate. The constructor requires data for name only. The rate should be set to the subscription rate of RateConstants. The name should not contain digits. If the name contains digits, raise an exception InvalidNameException.


Create a class name InvalidNameException. The NewspaperSubscription class should throw an exception named InvalidNameException when it receives an invalid subscriber’s name.


Create a class PhysicalNewspaperSubcription that extends NewspaperSubscription class. The PhysicalNewspaperSubscription class should have a field for subscription type and a constructor to sets the subscription type to “PhysicalSUB”. The PhysicalNewspaperSubscription class should also have a toString() method to displays all the information.


Create a class SubscriptionApp that creates at least 3 objects of PhysicalNewspaperSubscription class and save in the array of Subscription type. Prompt the user for all required information for the subscription. If an object would be created successfully, the object should be saved in an array otherwise a message should be displayed from InvalidNameException.


Sample Output:


 Enter information for object 1


Enter name


Mehwish Bashir


Information is saved in the database successfully


Enter information for object 2


Enter name


David 123


Invalid name


Enter information for object 3


 Enter name John K.


Information is saved in the database successfully


Displaying records


The subscriber's name : Mehwish Bashir  rate: $15.5  subscription type : PhysicalSUB


The subscriber's name : John K. rate: $15.5 subscription type : PhysicalSUB


Done

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here