eate 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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

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

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,