-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoice.java
More file actions
80 lines (65 loc) · 1.73 KB
/
Invoice.java
File metadata and controls
80 lines (65 loc) · 1.73 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
public class Invoice implements Payable {
private int partNumber;
private String partDescription;
private double quantity;
private double pricePerItem;
public Invoice(int partNumber, String partDescription, double quantity,double pricePerItem) {
this.partNumber=partNumber;
this.partDescription=partDescription;
if(quantity>=0) {
this.quantity=quantity;
}
else {
System.out.println("Warning");
}
if(pricePerItem>0) {
this.pricePerItem=pricePerItem;
}
else {
System.out.println("Warning");
}
}
public double getPaymentAmount() {
return getQuantity()* getPricePerItem();
}
private double getPricePerItem() {
return pricePerItem;
}
private void setPricePerItem(double pricePerItem) {
if(pricePerItem>0) {
this.pricePerItem=pricePerItem;
}
else {
System.out.println("Warning");
}
}
private double getPartNumber() {
return partNumber;
}
private void setPartNumber(int partNumber) {
this.partNumber = partNumber;
}
private String getPartDescription() {
return partDescription;
}
private void setPartDescription(String partDescription) {
this.partDescription = partDescription;
}
private double getQuantity() {
return quantity;
}
private void setQuantity(double quantity) {
if(quantity>=0) {
this.quantity=quantity;
}
else {
System.out.println("Warning");
}
}
public String toString() {
return "invoice:"+"\n"+
"part number: "+getPartNumber()+""+getPartDescription()+"\n"+
"quantity: "+getQuantity()+"\n"+
"price per item: "+getPricePerItem();
}
}