0% found this document useful (0 votes)
99 views3 pages

Department of Computer Science: Assignment 2

The document provides instructions to write code for a salon service program with classes for Customer, PremiumCustomer, and Visit, where PremiumCustomer extends Customer and can store multiple visit histories with a discount, while Customer only allows one visit; it includes details on the constructors, methods, and variables needed for each class and instructions to write test code to demonstrate the classes.

Uploaded by

aqsa ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views3 pages

Department of Computer Science: Assignment 2

The document provides instructions to write code for a salon service program with classes for Customer, PremiumCustomer, and Visit, where PremiumCustomer extends Customer and can store multiple visit histories with a discount, while Customer only allows one visit; it includes details on the constructors, methods, and variables needed for each class and instructions to write test code to demonstrate the classes.

Uploaded by

aqsa ismail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF COMPUTER SCIENCE

UW
Assigned Date: 30-10 – 19
ASSIGNMENT 2

Discipline/Semester: BSCS 3RD


Course Code: CS-212 Due Date: 08- 11 - 19
Course : Advanced Object Oriented Programming
Total Marks: 10
Note: Plagiarized assignments will be marked zero. Continuous plagiarism will result in negative
marking.

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.

Write code for class Visit. The class has:

 Variables: date, serviceCharges, productCharges


 Functions:
 A constructor that sets all the variables
 Setter and getter for each variable
 A function toString that returns the value of variables in a similar format :
Date: 10\11\2011
Service Charges: 200.0
Product Charges: 300.0
Write code for class Customer. The class has:

 Variables: name, a Visit class object.

Hint: You will need an ArrayList of Visit type objects “visitList”

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.

The class has:

 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

Write code for the testClass

 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.

Output can be similar to the following figure:

You might also like