-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPawnItem.java
140 lines (134 loc) · 3.21 KB
/
PawnItem.java
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
138
139
140
package pawnApp;
public class PawnItem {
String type;
String name;
float weight;
int karat;
double valueOfItem;
int id;
private PawnItem next;
public PawnItem(String name,String type, float weight, int karat, int id)
{
this.name = name;
this.type = type;
this.weight = weight;
this.karat = karat;
this.id = id;
this.next = null;
}
public double computeValue()
{
double val;
if (type.equals ("gold"))
{
switch (karat)
{
case 24: valueOfItem = (weight * 2176);
System.out.println(valueOfItem);
break;
case 22: valueOfItem = (weight * 1996);
break;
case 18: valueOfItem = (weight * 1664);
break;
case 14: valueOfItem = (weight * 1280);
break;
case 10: valueOfItem = (weight * 1000);
break;
default: System.out.println("invalid entry");
}
//System.out.println("The value of the item is "+value);
this.valueOfItem = valueOfItem;
val = amountGivenToCustomer();
}
else if (type.equals("silver"))
{
switch(karat)
{
case 24: valueOfItem = (weight * 2000);
break;
case 22: valueOfItem = (weight * 1800);
break;
case 18: valueOfItem = (weight * 1600);
break;
case 14: valueOfItem = (weight * 1400);
break;
case 10: valueOfItem = (weight * 1200);
break;
default: System.out.println("invalid entry");
}
//System.out.println("The value of the item is "+value);
this.valueOfItem = valueOfItem;
val = amountGivenToCustomer();
}
else
{
switch(karat)
{
case 24: valueOfItem = (weight * 4000);
break;
case 22: valueOfItem = (weight * 3800);
break;
case 18: valueOfItem = (weight * 3600);
break;
case 14: valueOfItem = (weight * 3400);
break;
case 10: valueOfItem = (weight * 3200);
break;
default: System.out.println("invalid entry");
}
//System.out.println("The value of the item is "+value);
this.valueOfItem = valueOfItem;
val = amountGivenToCustomer();
}
return val;
}
public double amountGivenToCustomer()
{
double amount = (valueOfItem * 0.75);
//System.out.println("The amount Given to customer for that item is "+amount);
return amount;
}
/*public double amountToBeReturned(double amt , int noOfDays)
{
double interest_rate_per_day = (0.1/365);
double interest_per_day = (interest_rate_per_day * amt);
double interest = (interest_per_day * noOfDays);
double amountToBeReturned = (amt + interest);
return amountToBeReturned;
}*/
public String getName()
{
return name;
}
public float getWeight()
{
return weight;
}
public int getKarat()
{
return karat;
}
public PawnItem getNext()
{
return next;
}
public void setNext(PawnItem nextItem)
{
this.next = nextItem;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return (this.id == ((PawnItem)obj).id);
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return 1;
}
@Override
public String toString() {
return "PawnItem [type=" + type + ", name=" + name + ", weight=" + weight + ", karat="
+ karat + ", valueOfItem=" + valueOfItem + ", id=" + id + "]";
}
}