Complete the following tasks: a. Create a class for a cell phone service named Message that includes a field for the price of the message. Create get and set methods for the field. b. Derive three...



Complete the following tasks:


a. Create a class for a cell phone service named Message that includes a field for


the price of the message. Create get and set methods for the field.


b. Derive three subclasses—VoiceMessage, TextMessage, and PictureMessage.


The VoiceMessage class includes a numeric field to hold the length of the


message in minutes and a get and set method for the field. When a


VoiceMessage’s length value is set, the price is calculated at 4 cents per minute.


The TextMessage class includes a numeric field to hold the length of the


message in words and a get and set method for the field. When a TextMessage’s


length value is set, the price is calculated at 2 cents per word. The


PictureMessage class includes a numeric field that holds the size of the picture


in kilobytes and get and set methods for the field. When a PictureMessage’s


length value is set, the price is calculated at 1 cent per kilobyte.


c. Design a program that instantiates one object of each of the three classes, and


demonstrate using all the methods defined for each class.

Nov 16, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here