質問編集履歴

2

・書き忘れていたTrainToyコードを追加したこと ・エラーコードのやり直し を致しました

2020/07/20 12:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -140,108 +140,150 @@
140
140
 
141
141
  ```
142
142
 
143
+ public class TrainToy {
144
+
145
+ String code_; //商品コード
146
+
147
+ int price_; //価格
148
+
149
+
150
+
151
+ //走る
152
+
153
+ public void go(){
154
+
155
+ System.out.println("ガタンゴトン");
156
+
157
+ }
158
+
159
+
160
+
161
+ //警笛を鳴らす
162
+
163
+ public void horn(){
164
+
165
+ System.out.println("プォー!");
166
+
167
+ }
168
+
169
+ }
170
+
171
+ ```
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+ ```
184
+
143
185
  Main.java:20: error: incompatible types: CarToy cannot be converted to String
144
186
 
145
- suzuki.checkPrice(car1, car2, train1);
187
+ suzuki.checkPrice(car1, car2, train1);
146
-
188
+
147
- ^
189
+ ^
148
190
 
149
191
  Main.java:23: error: incompatible types: CarToy cannot be converted to String
150
192
 
151
- suzuki.doDemo(car1, car2, train1);
193
+ suzuki.doDemo(car1, car2, train1);
152
-
194
+
153
- ^
195
+ ^
196
+
197
+ ShopKeeper.java:7: error: cannot find symbol
198
+
199
+ System.out.println("商品コード:" + kuruma1.code_
200
+
201
+ ^
202
+
203
+ symbol: variable code_
204
+
205
+ location: variable kuruma1 of type String
154
206
 
155
207
  ShopKeeper.java:8: error: cannot find symbol
156
208
 
157
- System.out.println("商品コード:" + kuruma1.code_
209
+ + "の価格は" + kuruma1.price_ + "円です。");
158
-
210
+
159
- ^
211
+ ^
212
+
213
+ symbol: variable price_
214
+
215
+ location: variable kuruma1 of type String
216
+
217
+ ShopKeeper.java:9: error: cannot find symbol
218
+
219
+ System.out.println("商品コード:" + kuruma2.code_
220
+
221
+ ^
160
222
 
161
223
  symbol: variable code_
162
224
 
225
+ location: variable kuruma2 of type String
226
+
227
+ ShopKeeper.java:10: error: cannot find symbol
228
+
229
+ + "の価格は" + kuruma2.price_ + "円です。");
230
+
231
+ ^
232
+
233
+ symbol: variable price_
234
+
235
+ location: variable kuruma2 of type String
236
+
237
+ ShopKeeper.java:11: error: cannot find symbol
238
+
239
+ System.out.println("商品コード:" + densya1.code_
240
+
241
+ ^
242
+
243
+ symbol: variable code_
244
+
245
+ location: variable densya1 of type String
246
+
247
+ ShopKeeper.java:12: error: cannot find symbol
248
+
249
+ + "の価格は" + densya1.price_ + "円です。");
250
+
251
+ ^
252
+
253
+ symbol: variable price_
254
+
255
+ location: variable densya1 of type String
256
+
257
+ ShopKeeper.java:20: error: cannot find symbol
258
+
259
+ kuruma1.go();
260
+
261
+ ^
262
+
263
+ symbol: method go()
264
+
163
265
  location: variable kuruma1 of type String
164
266
 
165
- ShopKeeper.java:9: error: cannot find symbol
267
+ ShopKeeper.java:22: error: cannot find symbol
166
-
268
+
167
- + "の価格は" + kuruma1.price_ + "円です。");
269
+ kuruma2.go();
168
-
270
+
169
- ^
271
+ ^
170
-
171
- symbol: variable price_
272
+
172
-
173
- location: variable kuruma1 of type String
174
-
175
- ShopKeeper.java:10: error: cannot find symbol
176
-
177
- System.out.println("商品コード:" + kuruma2.code_
178
-
179
- ^
180
-
181
- symbol: variable code_
273
+ symbol: method go()
182
274
 
183
275
  location: variable kuruma2 of type String
184
276
 
185
- ShopKeeper.java:11: error: cannot find symbol
277
+ ShopKeeper.java:24: error: cannot find symbol
186
-
278
+
187
- + "の価格は" + kuruma2.price_ + "円です。");
279
+ densya1.go();
188
-
280
+
189
- ^
281
+ ^
190
-
191
- symbol: variable price_
282
+
192
-
193
- location: variable kuruma2 of type String
194
-
195
- ShopKeeper.java:12: error: cannot find symbol
196
-
197
- System.out.println("商品コード:" + densya1.code_
198
-
199
- ^
200
-
201
- symbol: variable code_
283
+ symbol: method go()
202
284
 
203
285
  location: variable densya1 of type String
204
286
 
205
- ShopKeeper.java:13: error: cannot find symbol
206
-
207
- + "の価格は" + densya1.price_ + "円です。");
208
-
209
- ^
210
-
211
- symbol: variable price_
212
-
213
- location: variable densya1 of type String
214
-
215
- ShopKeeper.java:21: error: cannot find symbol
216
-
217
- kuruma1.go();
218
-
219
- ^
220
-
221
- symbol: method go()
222
-
223
- location: variable kuruma1 of type String
224
-
225
- ShopKeeper.java:23: error: cannot find symbol
226
-
227
- kuruma2.go();
228
-
229
- ^
230
-
231
- symbol: method go()
232
-
233
- location: variable kuruma2 of type String
234
-
235
- ShopKeeper.java:25: error: cannot find symbol
236
-
237
- densya1.go();
238
-
239
- ^
240
-
241
- symbol: method go()
242
-
243
- location: variable densya1 of type String
244
-
245
287
  Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
246
288
 
247
289
  ```

1

エラー内容の追記

2020/07/20 12:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -140,33 +140,109 @@
140
140
 
141
141
  ```
142
142
 
143
- public class TrainToy {
144
-
145
- String code_; //商品コード
146
-
147
- int price_; //価格
148
-
149
-
150
-
151
- //走る
152
-
153
- public void go(){
154
-
155
- System.out.println("ガタンゴトン");
156
-
157
- }
158
-
159
-
160
-
161
- //警笛を鳴らす
162
-
163
- public void horn(){
164
-
165
- System.out.println("プォー!");
166
-
167
- }
168
-
169
- }
143
+ Main.java:20: error: incompatible types: CarToy cannot be converted to String
144
+
145
+ suzuki.checkPrice(car1, car2, train1);
146
+
147
+ ^
148
+
149
+ Main.java:23: error: incompatible types: CarToy cannot be converted to String
150
+
151
+ suzuki.doDemo(car1, car2, train1);
152
+
153
+ ^
154
+
155
+ ShopKeeper.java:8: error: cannot find symbol
156
+
157
+ System.out.println("商品コード:" + kuruma1.code_
158
+
159
+ ^
160
+
161
+ symbol: variable code_
162
+
163
+ location: variable kuruma1 of type String
164
+
165
+ ShopKeeper.java:9: error: cannot find symbol
166
+
167
+ + "の価格は" + kuruma1.price_ + "円です。");
168
+
169
+ ^
170
+
171
+ symbol: variable price_
172
+
173
+ location: variable kuruma1 of type String
174
+
175
+ ShopKeeper.java:10: error: cannot find symbol
176
+
177
+ System.out.println("商品コード:" + kuruma2.code_
178
+
179
+ ^
180
+
181
+ symbol: variable code_
182
+
183
+ location: variable kuruma2 of type String
184
+
185
+ ShopKeeper.java:11: error: cannot find symbol
186
+
187
+ + "の価格は" + kuruma2.price_ + "円です。");
188
+
189
+ ^
190
+
191
+ symbol: variable price_
192
+
193
+ location: variable kuruma2 of type String
194
+
195
+ ShopKeeper.java:12: error: cannot find symbol
196
+
197
+ System.out.println("商品コード:" + densya1.code_
198
+
199
+ ^
200
+
201
+ symbol: variable code_
202
+
203
+ location: variable densya1 of type String
204
+
205
+ ShopKeeper.java:13: error: cannot find symbol
206
+
207
+ + "の価格は" + densya1.price_ + "円です。");
208
+
209
+ ^
210
+
211
+ symbol: variable price_
212
+
213
+ location: variable densya1 of type String
214
+
215
+ ShopKeeper.java:21: error: cannot find symbol
216
+
217
+ kuruma1.go();
218
+
219
+ ^
220
+
221
+ symbol: method go()
222
+
223
+ location: variable kuruma1 of type String
224
+
225
+ ShopKeeper.java:23: error: cannot find symbol
226
+
227
+ kuruma2.go();
228
+
229
+ ^
230
+
231
+ symbol: method go()
232
+
233
+ location: variable kuruma2 of type String
234
+
235
+ ShopKeeper.java:25: error: cannot find symbol
236
+
237
+ densya1.go();
238
+
239
+ ^
240
+
241
+ symbol: method go()
242
+
243
+ location: variable densya1 of type String
244
+
245
+ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
170
246
 
171
247
  ```
172
248
 
@@ -183,3 +259,5 @@
183
259
  kuruma1とdensya1の前に置かれるデータ型はStringだと思ったのですがエラーが出ます。
184
260
 
185
261
  なぜStringではなくCarToyやTrainToyといったクラス型がデータ型として置かれるのでしょうか?
262
+
263
+ 一番下にエラー内容を追記致しました。