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
Latest commit
86 lines (68 loc) · 2.32 KB
/
Copy pathSeller.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
packageAssignment;
publicclassSellerextendsPerson
{
privatedoubleprofitRate;
privatedoublesalesTaxRate;
privateAnimalanimal;
//constructor
publicSeller (Stringname , Stringid , Stringaddress , Stringcontact , doubleprofitRate , doublesalesTaxRate , Animalanimal)
{
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
publicdoublegetProfitRate()
{
returnprofitRate;
}
publicvoidsetProfitRate(doubleprofitRate)
{
this.profitRate = profitRate;
}
publicdoublegetSalesTaxRate()
{
returnsalesTaxRate;
}
publicvoidsetSalesTaxRate(doublesalesTaxRate)
{
this.salesTaxRate = salesTaxRate;
}
publicAnimalgetAnimal()
{
returnanimal;
}
publicvoidsetAnimal(Animalanimal)
{
this.animal = animal;
}
//method to calculate sellers profit
publicdoublegrossProfit()
{
returnanimal.price()*(profitRate/100);// will return the profit based on animal price and profit percentage
}
// method to calculate sales TAX
// Standard rate is 17%
publicdoubletax()
{
returngrossProfit() * (salesTaxRate/100);
}
// method to calculate net income/profit for the seller
publicdoublenetProfit()
{
returngrossProfit() - tax();
}
// method to calculate net income/profit for the seller
//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" , "Gross income :", grossProfit() ,"Tax on profit (17% is standard) :" , tax() , "Net profit for the seller :" , netProfit() );
}
// ToString method
publicStringtoString()
{
returnString.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());
}
}