Department of Computer Science: Assignment 2
Department of Computer Science: Assignment 2
UW
Assigned Date: 30-10 – 19
ASSIGNMENT 2
You need to write code for a Salon Service. For better customer management the Salon has divided
the customers into two classes; Customer and PremiumCustomer. The track of ordinary customers in
not maintained whereas the premium customers have a maintained history. Premium customer are
also able to get a discount of 20% in each purchase.
Remember the Customer class can only have one Visit object while a PremiumCustomer can have
more than one Visit objects.
Remember:
The Customer class can only have one Visit object. For Customer the size of this list cannot be
greater than zero.
Functions:
A constructor(String name,Visit v)
Setter and getter for all variables
getTotalExpense(): return serviceCharges+productCharges
toString(): return the message in the following form
Customer Name:Farrah
MemberShip:Customer No of visit:1
Date:10\11\2011
Service Charges: 200.0
Product Charges: 300.0
printBill(): print the bill in a similar form.
Hint: You must use an already created function
Customer Name:Farrah
MemberShip:Customer No of visit:1
Date:10\11\2011
Service Charges: 200.0
Product Charges: 300.0
Total:500.0
Write code for class PremiumCustomer. The class is a subtype of Customer class and Discountable
interface.
Functions:
A constructor that sets all variables.
addVisit(Date d1,double serviceCharges, double productCharges):
add a Visit type object to the “visitList” with the
getTotalExpense(): Get the values from the last element of visitList and calculate
Total . Then call the function discount (total) to return the remaining total.
Discount(double total): deduct 20% from the total and return it.
getCustomerHistory():
Iterate over all the list and call toString of all visit object
for(Visit i : super.visit){
}
getTotalNoOfVisit(): return the size of visitList.
printBill(): Prints the bill in the following format:
Hint: You need to use the functions from the parent class for printing the message
Customer Name:Aslam
MemberShip:PremiumCustomer No of visit:2
Date:10\11\2011
Service Charges: 400.0
Product Charges: 200.0
Create an object of Date , Visit and then use it to create an object c1 of Customer class.
Call the printBill method over c1.
Create an object of Date , Visit and then use it to create an object of PremiumCustomer class
p1.
Call printBill method over p1.
Add a visit to p1 and call printBill again.
Call printCustomerHistory of p1.