Provide details on what you need help with along with a budget and time limit. Questions are posted anonymously and can be made 100% private.
Match with a Tutor
Studypool matches you to the best tutor to help you with your question. Our tutors are highly qualified and vetted.
Get Quality Help
Your matched tutor provides personalized help according to your question details. Payment is made only after you have completed your 1-on-1 session and are satisfied with your session.
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
Would you like to help your fellow students? Are you in need of an additional source of income? Apply to become a tutor on Studypool! Our best tutors earn over $7,500 each month!