NewspaperSubscriber class- create an abstract class named NewspaperSubscriber with attributes to contain the subscriber’s street address and the subscription rate. Include get and set methods for both these attributes. The set method for the rate is abstract. The setAddress method must prompt the user to enter the subscriber’s address through the use of a dialog box. Create a constructor for the base class. Create a toString() method that concaternates and returns the subscriber’s street address and rate for display. Create 3 child classes named SevenDaySubscriber, Weekday Subscriber, and Weekend Subscriber. Each child class has an additional attribute called subType, which is a String, that will store the type of newspaper subscription. Create a setType method that will set the type of subscriber as follows: “Seven Day”, “Weekday”, or“Weekend”. Create a setRate method for each child class that sets the rate as follows: a SevenDaysubscriber pays R18.00 per week for his newspapers, a WeekdaySubscriber pays R15.00 per week, and a WeekendSubscriber pays R8.00 per week. Use child class constructors to control the setting of the rate. Each child class should include a toString() method that returns the string “Service type: “ and the subscriptionType as a a single concaternated string. Subscribers Test Driver Write an application named Subscribers that declares an array consisting of 6 NewspaperSubscribers. These subscribers can consist of any combination of weekly, weekday or weekend subscribers. The sequence of objects for which the user will enter data is not known in advance. Your application will be menu driven. Using a dialog box, prompt the user to specify the type of Newspaper Subscriber that must be created (1 for SevenDay Subscriber, 2 for Weekday Subscriber, or 3 for Weekend Subscriber). Thereafter, create the object based on the appropriate subscription type. After creation of all objects, display a single dialog box on the screen showing the data for all objects. Data displayed will include the inherited attributes as well as data specific to the child class for each object. The toString() method within the child class will override the parent class toString() method. The data for each object will be displayed on a separate line within the same dialog box. Save the files as NewspaperSubscriber.java, WeekdaySubscriber.java, WeekendSubscriber.java, SevenDaySubscriber.java and Subscribers.java.
NewspaperSubscriber class- create an abstract class named NewspaperSubscriber with attributes to contain the subscriber’s street address and the subscription rate. Include get and set methods for both these attributes. The set method for the rate is abstract. The setAddress method must prompt the user to enter the subscriber’s address through the use of a dialog box. Create a constructor for the base class. Create a toString() method that concaternates and returns the subscriber’s street address and rate for display.
Create 3 child classes named SevenDaySubscriber, Weekday Subscriber, and Weekend Subscriber. Each child class has an additional attribute called subType, which is a String, that will store the type of newspaper subscription. Create a setType method that will set the type of subscriber as follows: “Seven Day”, “Weekday”, or“Weekend”. Create a setRate method for each child class that sets the rate as follows: a SevenDaysubscriber pays R18.00 per week for his newspapers, a WeekdaySubscriber pays R15.00 per week, and a WeekendSubscriber pays R8.00 per week. Use child class constructors to control the setting of the rate. Each child class should include a toString() method that returns the string “Service type: “ and the subscriptionType as a a single concaternated string.
Subscribers Test Driver
Write an application named Subscribers that declares an array consisting of 6 NewspaperSubscribers. These subscribers can consist of any combination of weekly, weekday or weekend subscribers.
The sequence of objects for which the user will enter data is not known in advance.
Your application will be menu driven. Using a dialog box, prompt the user to specify the type of Newspaper Subscriber that must be created (1 for SevenDay Subscriber, 2 for Weekday Subscriber, or 3 for Weekend Subscriber). Thereafter, create the object based on the appropriate subscription type.
After creation of all objects, display a single dialog box on the screen showing the data for all objects. Data displayed will include the inherited attributes as well as data specific to the child class for each object. The toString() method within the child class will override the parent class toString() method. The data for each object will be displayed on a separate line within the same dialog box.
Save the files as NewspaperSubscriber.java, WeekdaySubscriber.java, WeekendSubscriber.java, SevenDaySubscriber.java and Subscribers.java.
Step by step
Solved in 2 steps with 2 images