forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuyer.java
More file actions
Latest commit
58 lines (44 loc) · 1.55 KB
/
Copy pathBuyer.java
File metadata and controls
58 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
packageAssignment;
publicclassBuyerextendsPerson
{
privateAnimalanimal;
privateDatetransactionDate;
publicBuyer(Stringname , Stringid , Stringaddress , Stringcontact , Animalanimal , DatetransactionDate)
{
super(name, id, address, contact);
this.animal = animal;
this.transactionDate = transactionDate;
}
publicAnimalgetAnimal()
{
returnanimal;
}
publicvoidsetAnimal(Animalanimal)
{
this.animal = animal;
}
publicAnimalgettransactionDate()
{
returnanimal;
}
publicvoidsettransactionDate(Animalanimal)
{
this.animal = animal;
}
//method to calculate the total amount to be paid
publicdoubledueAmount()
{
returnanimal.getServicesCharges() + animal.price();
}
// it is a commom method that keeps track of the finance of each class
//not added in to string method can only be shown when specifically called
publicvoidmanageFinance()
{
System.out.printf("%-25s%s%n%-25s%s%n%-25s%s%n" , "Animal Service Charges :" , animal.getServicesCharges() , "Animal's Price :" , animal.price() , "Total Amount to be Payed" , dueAmount());
}
// tostring method
publicStringtoString()
{
returnString.format("%s%n%s%-25s%s%n%-25s%s%n","----------- Buyer Information -----------",super.toString() ,"Amount To Be Paid :" , dueAmount(), "Date of Transaction :" , transactionDate);
}
}