-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoubleField.java
36 lines (31 loc) · 884 Bytes
/
DoubleField.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
import java.text.DecimalFormat;
import java.util.logging.Level;
public class DoubleField extends Field {
private double value;
//Changes how the decimal is formatted as a string.
private static final DecimalFormat df = new DecimalFormat("#.00");
/**
* Create a new double field with the name name and the value val
* @param name The name of the field
* @param val The value to set it to.
*/
public DoubleField(String name, double val, Level level) {
super(name, level);
value = val;
}
/**
* Returns a formatted decimal
* @return The formatted decimal.
*/
@Override
public String toString() {
return df.format(value);
}
/**
* Changes the current value
* @param val The new value to set
*/
public void setValue(double val) {
value = val;
}
}