Question: 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.

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.

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Here is a class for a cell phone service named Message that includes a field for the price of the message with get and set methods for the field cla... 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 Programming Logic & Design Questions!