forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
Latest commit
137 lines (109 loc) · 3.12 KB
/
Copy pathAnimal.java
File metadata and controls
137 lines (109 loc) · 3.12 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
packageAssignment;
publicclassAnimalextendsMaintainFinance
{
privateStringtype;
privateStringidTag;
privateStringcolor;
privatedoubleweight;
privatedoublepricePerKg;
privateDatearrivalDate;
privatelongservicesCharges;
privatebooleananimalStatus;
// Constructor
publicAnimal(Stringtype, StringidTag, Stringcolor, doubleweight, doublepricePerKg, DatearrivalDate,longservicesCharges, booleananimalStatus)
{
this.type = type;
this.idTag = idTag;
this.color = color;
this.weight = weight;
this.pricePerKg = pricePerKg;
this.arrivalDate = arrivalDate;
this.servicesCharges = servicesCharges;
this.animalStatus = animalStatus;
}
// Getter and setters
publicStringgetType()
{
returntype;
}
publicvoidsetType(Stringtype)
{
this.type = type;
}
publicStringgetIdTag()
{
returnidTag;
}
publicvoidsetIdTag(StringidTag)
{
this.idTag = idTag;
}
publicStringgetColor()
{
returncolor;
}
publicvoidsetColor(Stringcolor)
{
this.color = color;
}
publicdoublegetWeight()
{
returnweight;
}
publicvoidsetWeight(doubleweight)
{
this.weight = weight;
}
publicdoublegetPricePerKg()
{
returnpricePerKg;
}
publicvoidsetPricePerKg(doublepricePerKg)
{
this.pricePerKg = pricePerKg;
}
publicDategetArrivalDate()
{
returnarrivalDate;
}
publicvoidsetArrivalDate(DatearrivalDate)
{
this.arrivalDate = arrivalDate;
}
publiclonggetServicesCharges()
{
returnservicesCharges;
}
publicvoidsetServicesCharges(longservicesCharges)
{
this.servicesCharges = servicesCharges;
}
publicbooleangetAnimalStatus()
{
returnanimalStatus;
}
publicvoidsetAnimalStatus(booleananimalStatus)
{
this.animalStatus = animalStatus;
}
//method to calculate the price of animal based on its weight and price per KG
publicdoubleprice()
{
returnweight*pricePerKg;
}
//common method for all the classes
//here it calculates the price of animal based on its weight and price per KG
@Override
publicvoidmanageFinance()
{
System.out.println("Price of the animal is :" + price());
}
publicStringtoString()
{
returnString.format(
"%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n%-25s%s%n" ,"----------- Animal Information -----------",
"Type :", type , "Identification Tag :" , idTag , "Color :" , color , "Weight :" , weight ,
"Price Per KG :" , pricePerKg , "Arrival Date :" , arrivalDate , "Service Charges :" ,servicesCharges ,
"Animal's Price :" , price() ,"Animal Status :", animalStatus );
}
}