forked from Kitch05/Vending-Machine-with-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoney.java
More file actions
68 lines (59 loc) · 1.54 KB
/
Copy pathMoney.java
File metadata and controls
68 lines (59 loc) · 1.54 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
/**
* This class represent a money with a specific value denomination and a given count/stack.
*/
public class Money {
private double value;
private int count;
/**
* Class Constructor.
*
* @param value a valid denomination.
* @param count the number of count there is as a stack.
*/
public Money(double value, int count) {
this.value = value;
this.count = count;
}
/**
* Returns the denomination of this object
*
* @return a double value.
*/
public double getValue() {
return this.value;
}
/**
* Returns the count of this object as a stack.
*
* @return an int value.
*/
public int getCount() {
return this.count;
}
/**
* Allows the user to change the count of the stack.
*
* @param amount the amount to be added to the current count.
*/
public void changeCount(int amount) {
this.count += amount;
}
/**
* Returns the string format of all the details in about this object.
*
* @return a string.
*/
public String toString() {
String denomination = null;
if(this.value >= 20) {
denomination = "peso bill";
}
else if(this.value >= 1) {
denomination = "peso coin";
}
else{
denomination = "cent";
}
return this.value + " " + denomination + " ---- " + this.count + " remaining";
}
}