forked from ghostmkg/programming-language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeller.java
More file actions
86 lines (68 loc) · 2.32 KB
/
Seller.java
File metadata and controls
86 lines (68 loc) · 2.32 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
package Assignment;
public class Seller extends Person
{
private double profitRate;
private double salesTaxRate;
private Animal animal;
//constructor
public Seller (String name , String id , String address , String contact , double profitRate , double salesTaxRate , Animal animal)
{
super(name, id, address, contact);
this.profitRate = profitRate;
this.salesTaxRate = salesTaxRate;
this.animal = animal; // to get access to the price method of animal
}
//getter and setters
public double getProfitRate()
{
return profitRate;
}
public void setProfitRate(double profitRate)
{
this.profitRate = profitRate;
}
public double getSalesTaxRate()
{
return salesTaxRate;
}
public void setSalesTaxRate(double salesTaxRate)
{
this.salesTaxRate = salesTaxRate;
}
public Animal getAnimal()
{
return animal;
}
public void setAnimal(Animal animal)
{
this.animal = animal;
}
//method to calculate sellers profit
public double grossProfit()
{
return animal.price()*(profitRate/100);// will return the profit based on animal price and profit percentage
}
// method to calculate sales TAX
// Standard rate is 17%
public double tax()
{
return grossProfit() * (salesTaxRate/100);
}
// method to calculate net income/profit for the seller
public double netProfit()
{
return grossProfit() - tax();
}
// method to calculate net income/profit for the seller
//not added in to string method can only be shown when specifically called
public void manageFinance()
{
System.out.printf("%-25s%s%n-25s%s%n-25s%s%n" , "Gross income :", grossProfit() ,"Tax on profit (17% is standard) :" , tax() , "Net profit for the seller :" , netProfit() );
}
// ToString method
public String toString()
{
return String.format("%s%n%s%-25s%s%n%-25s%s%n%-25s%s%n", "----------- Seller Information -----------" , super.toString() ,
"Seller's Gross profit :", grossProfit(),"Tax On Profit :", tax() , "Seller's Net Profit :" , netProfit());
}
}