(first class java) make a program

User Generated

zmxmw

Computer Science

Description

do what the assignment ask for

(zoom in to read )


Unformatted Attachment Preview

CPS 141 Assignment # 15 Due: Friday December 1, 2017 Create a Java RegularCustomer class to represent information about a customer at a store, who always get a 5% discount on purchases. It should include two fields (data members), one for the customer's name and one for their phone number. Include a parameterized constructor, setters, getters, toString, equals, and a copy OR copy constructor methods. The equals method only compares the phone numbers. Also, include a method called getDiscount Price, which receives the price of an item and returns the discounted price after a 5% discount. Be sure to include comments with the methods. Create a Java PreferredCustomer class that inherits from the RegularCustomer class. PreferredCustomers have a variable rate discount, which is always at least 5%. This class has one new data members, discount rate. Include a parameterized constructor, setters and getters for the discount rate, and a toString method that uses the toString of the RegularCustomer class and appends the discount rate to the String, formatted nicely. The discount rate should be prevented from being below 5%. Also, include a new version of the method called getDiscountPrice, which receives the price of an item and returns the discounted price after the discount rate discount is applied. Write a Java program to test your RegularCustomer and PreferredCustomer classes. This is a testing program, designed by a programmer to test their classes. It is does not need to be “user friendly”. Create two RegularCustomers and two PreferredCustomers(whose discount rates are 10% and 20%), and store all four in one ArrayList that can store only Regular Customers and its children. To test your equals method, create a RegularCustomer that has the same phone number as one of the item in the ArrayList, but a different name, and use the ArrayList indexOf method the display the index of the matching item in the ArrayList. Use a loop to iterate through the ArrayList and display each item AND use the getDiscountPrice method to display the discounted price if the customer buys an item with a regular price of $100.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

I have done what the assi...


Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags