Normand Briere
2019-04-22 a9e12f6c508810604c8c91ee15451776b08ce1a1
timeflow/format/field/FieldFormat.java
....@@ -4,61 +4,65 @@
44
55 import timeflow.data.time.*;
66
7
-public abstract class FieldFormat {
8
- protected String lastInput;
9
- protected Object lastValue;
10
- protected boolean understood=true;
11
-
12
- double value;
13
-
14
- void add(double x)
15
- {
16
- value+=x;
17
- }
18
-
19
- void note(String s)
20
- {
21
- add(scoreFormatMatch(s));
22
- }
7
+public abstract class FieldFormat
8
+{
9
+ protected String lastInput;
10
+ protected Object lastValue;
11
+ protected boolean understood = true;
12
+ double value;
2313
24
-
25
- protected abstract Object _parse(String s) throws Exception;
26
- public abstract String format(Object o);
27
- public abstract Class getType();
28
- public abstract double scoreFormatMatch(String s);
29
- public abstract String getHumanName();
14
+ void add(double x)
15
+ {
16
+ value += x;
17
+ }
3018
19
+ void note(String s)
20
+ {
21
+ add(scoreFormatMatch(s));
22
+ }
3123
32
- public void setValue(Object o)
33
- {
34
- lastValue=o;
35
- lastInput=o==null ? "" : format(o);
36
- }
37
-
38
- public Object parse(String s) throws Exception
39
- {
40
- lastInput=s;
41
- lastValue=null;
42
- understood=false;
43
- lastValue=_parse(s);
44
- understood=true;
45
- return lastValue;
46
- }
47
-
48
- public Object getLastValue()
49
- {
50
- return lastValue;
51
- }
52
-
53
- public String feedback()
54
- {
55
- if (!understood)
56
- return "Couldn't understand";
57
- return lastValue==null ? "(missing)" : "Read: "+format(lastValue);
58
- }
59
-
60
- public boolean isUnderstood()
61
- {
62
- return understood;
63
- }
24
+ protected abstract Object _parse(String s) throws Exception;
25
+
26
+ public abstract String format(Object o);
27
+
28
+ public abstract Class getType();
29
+
30
+ public abstract double scoreFormatMatch(String s);
31
+
32
+ public abstract String getHumanName();
33
+
34
+ public void setValue(Object o)
35
+ {
36
+ lastValue = o;
37
+ lastInput = o == null ? "" : format(o);
38
+ }
39
+
40
+ public Object parse(String s) throws Exception
41
+ {
42
+ lastInput = s;
43
+ lastValue = null;
44
+ understood = false;
45
+ lastValue = _parse(s);
46
+ understood = true;
47
+ return lastValue;
48
+ }
49
+
50
+ public Object getLastValue()
51
+ {
52
+ return lastValue;
53
+ }
54
+
55
+ public String feedback()
56
+ {
57
+ if (!understood)
58
+ {
59
+ return "Couldn't understand";
60
+ }
61
+ return lastValue == null ? "(missing)" : "Read: " + format(lastValue);
62
+ }
63
+
64
+ public boolean isUnderstood()
65
+ {
66
+ return understood;
67
+ }
6468 }