forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoice.java
More file actions
Latest commit
95 lines (72 loc) · 2.26 KB
/
Copy pathInvoice.java
File metadata and controls
95 lines (72 loc) · 2.26 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
packageAssignment;
publicclassInvoiceextendsMaintainFinance
{
privateBuyerbuyer;
privateDealerdealer;
privateAnimalanimal;
privateSellerseller;
publicInvoice(Buyerbuyer , Dealerdealer , Animalanimal, Sellerseller)
{
this.buyer = buyer;
this.dealer = dealer;
this.animal = animal;
this.seller = seller;
}
//getter and setter
publicBuyergetBuyer()
{
returnbuyer;
}
publicvoidsetBuyer(Buyerbuyer)
{
this.buyer = buyer;
}
publicDealergetDealer()
{
returndealer;
}
publicvoidsetDealer(Dealerdealer)
{
this.dealer = dealer;
}
publicAnimalgetAnimal()
{
returnanimal;
}
publicvoidsetAnimal(Animalanimal)
{
this.animal = animal;
}
publicSellergetSeller()
{
returnseller;
}
publicvoidsetSeller(Sellerseller)
{
this.seller = seller;
}
//method to calculate the total amount to be deposited (includes buyer + dealer + 7% tax)
publicdoubletotalAmount()
{
doubletotal = dealer.commision() + buyer.dueAmount();
doubletax = total * 0.07;
doubleamountToPay = tax + total;
//sets animal status as sold i.e sold
animal.setAnimalStatus(true);
returnamountToPay;
}
// 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 " , "Total amount to be paid : ", totalAmount());
}
//to string method
publicStringtoString()
{
returnString.format("%s%n%s%n%s%n%s%n%s%n%s%n%s%n%s%n%-25s%s%n%s","=========================================="
,"----------------- Invoice ----------------" ,"==========================================\n"
, animal.toString() , dealer.toString() , buyer.toString() , seller.toString(), "==========================================",
"Net Total to be paid :", totalAmount(), "==========================================");
}
}