Jay Patel

Jay Patel

  • NA
  • 21
  • 13.7k

class inheritance

Mar 1 2015 12:25 AM

Create an application named OrderDemo that declares and uses Order objects. The Order class performs order processing of a single item that sells for $19.95 each. The class has four variable fields that hold an order number, customer name, quantity ordered, and total price. Create a constructor that requires parameters for all the fields except total price. Include public get and set accessors for each field except the total price field; that field is calculated as quantity ordered times unit price (19.95) whenever the quantity is set, so it needs only a get accessor. Also create the following for the class:

a. An IsEquals() method that determines two Orders are equal if they have the same order number

b. A TellAboutSelf() method that returns a string containing all order information

The OrderDemo application declares a few Order objects and sets their values. Make sure to create at least two orders with the same order number. Display the string from the TellAboutSelf () method for each order. Write a method that compares two orders at a time and displays a message if they are equal. Send the Orders you created to the method two at a time and display the results.

Using the Order class you created, write a new application named OrderDemo2 that creates an array of five Orders. Prompt the user for values for each Order. Do not allow duplicate order numbers; force the user to reenter the order when a duplicate order number is entered. When five valid orders have been entered, display them all, plus a total of all orders.

Create a ShippedOrder class that derives from Order. A ShippedOrder has a $4.00 shipping fee (no matter how many items are ordered). Override any methods in the parent class as necessary. Write a new application named OrderDemo3 that creates an array of five ShippedOrders. Prompt the user for values for each, and do not allow duplicate order numbers—force the user to reenter the order when a duplicate order number is entered. When five valid orders have been entered, display them all, plus a total of all orders.


Answers (2)