teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

車のデータを追加しました。

2022/09/14 11:39

投稿

inori333
inori333

スコア4

title CHANGED
File without changes
body CHANGED
@@ -270,6 +270,38 @@
270
270
  }
271
271
 
272
272
 
273
+
274
+
275
+ アルファード,3597000,1,1,1,0,1,0,0,1,1,1
276
+ ハイエース,2903600,1,1,1,0,0,0,0,0,1,0
277
+ プリウス,2597000,1,1,1,0,1,0,1,0,0,0
278
+ ハリアー,2990000,1,1,1,1,1,0,0,0,0,0
279
+ ランドクルーザー,5100000,1,1,1,1,1,0,1,0,1,0
280
+ アクア,1980000,1,1,1,0,0,0,0,0,0,0
281
+ ヴォクシー,3090000,1,1,1,0,1,0,0,0,1,0
282
+ ヴェルファイア,4306000,1,1,1,0,0,0,0,1,1,1
283
+ クラウン,4350000,1,1,1,1,1,1,1,0,0,0
284
+ GR86,2799000,1,1,1,0,1,0,0,0,0,0
285
+ ノア,2670000,1,1,1,0,0,0,0,0,1,0
286
+ シエンタ,1818500,1,1,1,0,0,0,0,0,1,0
287
+ ハイラックス,4312000,1,1,1,0,0,0,0,0,0,0
288
+ RAV4,2774000,1,1,1,0,0,0,0,0,0,0
289
+ ヤリスクロス,1896000,1,1,1,0,0,0,0,0,0,0
290
+ ライズ,1707000,1,1,1,0,1,0,0,0,0,0
291
+ ルーミー,1556500,1,1,1,0,1,0,0,0,0,0
292
+ カローラスポーツ,2169000,1,1,1,0,0,0,0,0,0,0
293
+ パッソ,1265000,1,0,1,0,1,0,0,0,0,0
294
+ カムリ,3495000,1,1,1,1,0,0,0,0,0,0
295
+ カローラフィールダー,1709400,1,1,1,0,0,0,0,0,0,0
296
+ カローラクロス,1999000,1,0,1,0,0,0,0,0,0,0
297
+ カローラツーリング,2013000,1,1,1,0,1,0,0,0,0,0
298
+ スープラ,4995000,1,1,1,1,1,0,0,0,0,0
299
+ C-HR,2792000,1,1,1,0,1,0,0,0,0,0
300
+ MIRAI,7100000,1,1,1,1,1,1,1,0,0,0
301
+ コペン,2382200,1,1,1,0,1,0,0,0,0,0
302
+
303
+
304
+
273
305
  ```
274
306
 
275
307
  ### 試したこと

1

ソースコードの欄にMain.javaを追加し、補足情報を書き直しました。マークダウンについてはよくわからなかったので「-------」を消し、改行のみにしました。

2022/09/14 11:29

投稿

inori333
inori333

スコア4

title CHANGED
File without changes
body CHANGED
@@ -95,7 +95,10 @@
95
95
  }
96
96
  }
97
97
 
98
- ---------------------------------------------------------
98
+
99
+
100
+
101
+
99
102
  import java.util.ArrayList;
100
103
 
101
104
  public class Car_register {
@@ -220,77 +223,53 @@
220
223
  }
221
224
  }
222
225
  }
226
+ }
223
227
 
228
+
229
+
230
+
231
+
232
+
233
+
234
+ import java.util.Scanner;
235
+
236
+ public class Main {
224
- static void carsearch_1(int max, int min){
237
+ public static void main(String[] args){
225
- for(int j = 0; j < 27; j++){
226
- car_data[j] = name.get(j);
227
- car_price[j] = price.get(j);
238
+ CarOption car = new CarOption(args[0]);
228
- car_key[j] = key.get(j);
239
+ car.registration();
229
- car_smart[j] = smart.get(j);
240
+
230
- car_sheet[j] = sheet.get(j);
231
- car_power[j] = power.get(j);
241
+ Scanner sc = new Scanner(System.in);
242
+ System.out.println("/MENU/");
243
+ System.out.println("「0」車一覧「1」検索「2」終了 ");
232
- car_heater[j] = heater.get(j);
244
+ int a = Integer.parseInt(sc.next());
245
+
233
- car_cooler[j] = cooler.get(j);
246
+ while (true) {
247
+ if (a == 0) {
234
- car_leather[j] = leather.get(j);
248
+ car.display();
235
- car_ottoman[j] = ottoman.get(j);
236
- car_monitor[j] = monitor.get(j);
237
- car_three[j] = three.get(j);
238
- }
239
- for(int i = 0; i < 27; i++){
249
+ } else if (a == 1) {
240
- if(price.get(i) >= min && max > price.get(i)){
241
- System.out.println("名前:" + name.get(i) + "," + "値段:" + price.get(i) + "円");
242
- cnt2++;
243
- System.out.println("オプション一覧");
250
+ System.out.println("検索の仕方を選択してください");
244
- if(car_key[i] == 1){
245
- System.out.printf("キーレス,");
246
- cnt++;
247
- }
248
- if(car_smart[i] == 1){
249
- System.out.printf("スマートキー,");
250
- cnt++;
251
- }
252
- if(car_power[i] == 1){
253
- System.out.printf("パワーウィンドウ,");
254
- cnt++;
255
- }
256
- if(car_sheet[i] == 1){
257
- System.out.printf("ベンチシート,");
258
- cnt++;
259
- }
260
- if(car_heater[i] == 1){
261
- System.out.printf("シートヒーター,");
262
- cnt++;
263
- }
264
- if(car_cooler[i] == 1){
265
- System.out.printf("シートクーラー,");
266
- cnt++;
267
- }
268
- if(car_leather[i] == 1){
269
- System.out.printf("本革シート,");
270
- cnt++;
271
- }
272
- if(car_three[i] == 1){
273
- System.out.printf("3列シート,");
274
- cnt++;
275
- }
276
- if(car_monitor[i] == 1){
277
- System.out.println("後席モニター");
251
+ System.out.println("「0」車種名「1」値段「2」オプション");
278
- cnt++;
252
+ int b = Integer.parseInt(sc.next());
279
- }
280
- if(cnt == 0){
253
+ if(b == 0){
281
- System.out.println("オプションはありません");
282
- }
283
- cnt = 0;
254
+ car.search_0();
284
- }else{
255
+ }else if(b == 1){
256
+ car.search_1();
285
- if(cnt2 == 0 && i == 26){
257
+ }else if(b == 2){
286
- System.out.println("該当する車種は存在しません");
287
- cnt2 = 0;
258
+ car.search_2();
288
- }
289
259
  }
260
+ } else if (a == 2) {
261
+ System.out.println("ありがとうございました");
262
+ break;
290
263
  }
264
+ System.out.println("/MENU/");
265
+ System.out.println("「0」車一覧「1」検索「2」終了 ");
266
+ a = Integer.parseInt(sc.next());
291
267
  }
268
+ sc.close();
269
+ }
292
270
  }
293
271
 
272
+
294
273
  ```
295
274
 
296
275
  ### 試したこと
@@ -298,4 +277,3 @@
298
277
 
299
278
  ### 補足情報(FW/ツールのバージョンなど)
300
279
 
301
- 今回、クラスが2つあるのでソースコードの欄で「------」で区切っています。