Question: Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and rate. Include get and set methods for the name field and get

Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and rate.  Include get and set methods for the name field and get methods for the address and subscription rate; the setAddress() method is abstract. Create two subclasses named PhysicalNewspaperSubscription and OnlineNewspaperSubscription.  

The parameter for the setAddress() method of the PhysicalNewspaperSubscription class must contain at least one digit; otherwise, an error message is displayed and the subscription rate is set to 0. If the address is valid, the subscription rate is assigned $15. The parameter for the setAddress() method of the OnlineNewspaperSubscription class must contain an at sign (@) or an error message is displayed. If the address is valid, the subscription rate is assigned $9. 

Finally, write an application that declares several objects of both subscription subtypes and displays their data fields. Save the files as NewspaperSubscription.java, PhysicalNewspaperSubscription.java, OnlineNewspaperSubscription. java, and DemoSubscriptions.java.

Step by Step Solution

3.54 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public abstract class NewspaperSubscription protected String name protected ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!