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
95 lines (72 loc) · 2.26 KB
/
Invoice.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
package Assignment;
public class Invoice extends MaintainFinance
{
private Buyer buyer;
private Dealer dealer;
private Animal animal;
private Seller seller;
public Invoice(Buyer buyer , Dealer dealer , Animal animal, Seller seller)
{
this.buyer = buyer;
this.dealer = dealer;
this.animal = animal;
this.seller = seller;
}
//getter and setter
public Buyer getBuyer()
{
return buyer;
}
public void setBuyer(Buyer buyer)
{
this.buyer = buyer;
}
public Dealer getDealer()
{
return dealer;
}
public void setDealer(Dealer dealer)
{
this.dealer = dealer;
}
public Animal getAnimal()
{
return animal;
}
public void setAnimal(Animal animal)
{
this.animal = animal;
}
public Seller getSeller()
{
return seller;
}
public void setSeller(Seller seller)
{
this.seller = seller;
}
//method to calculate the total amount to be deposited (includes buyer + dealer + 7% tax)
public double totalAmount()
{
double total = dealer.commision() + buyer.dueAmount();
double tax = total * 0.07;
double amountToPay = tax + total;
//sets animal status as sold i.e sold
animal.setAnimalStatus(true);
return amountToPay;
}
// 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
public void manageFinance()
{
System.out.printf("%-25s%s%n " , "Total amount to be paid : ", totalAmount());
}
//to string method
public String toString()
{
return String.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(), "==========================================");
}
}