回答編集履歴
1
プログラム変更
test
CHANGED
@@ -40,6 +40,16 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
+
protected void setValue(double value) {
|
44
|
+
|
45
|
+
this.value = value;
|
46
|
+
|
47
|
+
this.times++;
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
43
53
|
public double getValue() {
|
44
54
|
|
45
55
|
return value;
|
@@ -58,9 +68,7 @@
|
|
58
68
|
|
59
69
|
public void plus(double x) {
|
60
70
|
|
61
|
-
value +
|
71
|
+
setValue(value + x);
|
62
|
-
|
63
|
-
times++;
|
64
72
|
|
65
73
|
}
|
66
74
|
|
@@ -68,9 +76,7 @@
|
|
68
76
|
|
69
77
|
public void minus(double x) {
|
70
78
|
|
71
|
-
value -
|
79
|
+
setValue(value - x);
|
72
|
-
|
73
|
-
times++;
|
74
80
|
|
75
81
|
}
|
76
82
|
|
@@ -78,9 +84,7 @@
|
|
78
84
|
|
79
85
|
public void multiplied(double x) {
|
80
86
|
|
81
|
-
value *
|
87
|
+
setValue(value * x);
|
82
|
-
|
83
|
-
times++;
|
84
88
|
|
85
89
|
}
|
86
90
|
|
@@ -88,9 +92,7 @@
|
|
88
92
|
|
89
93
|
public void divided(double x) {
|
90
94
|
|
91
|
-
value /
|
95
|
+
setValue(value / x);
|
92
|
-
|
93
|
-
times++;
|
94
96
|
|
95
97
|
}
|
96
98
|
|
@@ -118,7 +120,7 @@
|
|
118
120
|
|
119
121
|
public void plus(double x, int n) {
|
120
122
|
|
121
|
-
|
123
|
+
setValue(getValue() + x * n);
|
122
124
|
|
123
125
|
}
|
124
126
|
|
@@ -126,11 +128,13 @@
|
|
126
128
|
|
127
129
|
public void multiplied(double x, int n) {
|
128
130
|
|
129
|
-
|
131
|
+
double value = getValue();
|
130
132
|
|
131
|
-
|
133
|
+
for(int i=0; i<n; i++)
|
132
134
|
|
133
|
-
|
135
|
+
value *= x;
|
136
|
+
|
137
|
+
setValue(value);
|
134
138
|
|
135
139
|
}
|
136
140
|
|