init commit
This commit is contained in:
6
Question22-FunctionAndLambda/src/Calc.java
Normal file
6
Question22-FunctionAndLambda/src/Calc.java
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
public class Calc {
|
||||
public int addition(int randomNumber1, int randomNumber2, int randomNumber3) {
|
||||
return randomNumber1 + randomNumber2 + randomNumber3;
|
||||
}
|
||||
}
|
||||
24
Question22-FunctionAndLambda/src/Car.java
Normal file
24
Question22-FunctionAndLambda/src/Car.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
import java.util.Random;
|
||||
|
||||
public class Car {
|
||||
String color;
|
||||
int gasoline;
|
||||
Driver driverInfo;
|
||||
|
||||
int run() {
|
||||
this.gasoline--;
|
||||
|
||||
if (gasoline < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
int distance = random.nextInt(15) + 1;
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
51
Question22-FunctionAndLambda/src/Driver.java
Normal file
51
Question22-FunctionAndLambda/src/Driver.java
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
public class Driver {
|
||||
private String user;
|
||||
private long licenseNumber;
|
||||
private int age;
|
||||
private String address;
|
||||
|
||||
public Driver(String user, long licenseNumber, int age, String address) {
|
||||
this.user = user;
|
||||
this.licenseNumber = licenseNumber;
|
||||
this.age = age;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public long getLicenseNumber() {
|
||||
return licenseNumber;
|
||||
}
|
||||
|
||||
public void setLicenseNumber(long licenseNumber) {
|
||||
this.licenseNumber = licenseNumber;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void displayInfo(String carColor) {
|
||||
System.out.println(carColor + "色の車に乗っています");
|
||||
System.out.println( "名前:" + this.user + "\t" + "免許番号:" + this.licenseNumber + "\t" + "年齢:" + this.age + "\t" + "住所" + this.address);
|
||||
}
|
||||
}
|
||||
36
Question22-FunctionAndLambda/src/PTra22_01.java
Normal file
36
Question22-FunctionAndLambda/src/PTra22_01.java
Normal file
@@ -0,0 +1,36 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* PTra22_01.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
public class PTra22_01 {
|
||||
public List<String> createUsersInfo(List<User> list) {
|
||||
List<String> usersInfo = new ArrayList<>();
|
||||
for (User userInfo : list) {
|
||||
usersInfo.add(userInfo.toString());
|
||||
}
|
||||
return usersInfo;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<User> list = new ArrayList<>();
|
||||
User user = new User("田中太郎", "tanaka@hoge,.com", "tanaka@0000");
|
||||
User user2 = new User("鈴木一郎", "suzuki@hoge,.com", "suzuki@1111");
|
||||
User user3 = new User("山田二郎", "yamada@hoge,.com", "yamada@2222");
|
||||
list.add(user);
|
||||
list.add(user2);
|
||||
list.add(user3);
|
||||
|
||||
/*
|
||||
* TODO 以下処理を作成してください。
|
||||
* 変数にcreateUsersInfoを代入してください
|
||||
* createUsersInfoを実行してください
|
||||
* 取得したリストを表示してください
|
||||
*
|
||||
*/
|
||||
}
|
||||
}
|
||||
95
Question22-FunctionAndLambda/src/PTra22_02.java
Normal file
95
Question22-FunctionAndLambda/src/PTra22_02.java
Normal file
@@ -0,0 +1,95 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* PTra22_02.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
public class PTra22_02 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// ※この問題はPTra10_05で作成したCarクラスを使用して解いてください。
|
||||
// 目的地までの距離
|
||||
final int DISTANCE = 300;
|
||||
|
||||
// 1台目
|
||||
Car car1 = new Car();
|
||||
Driver driver1 = new Driver("田中太郎", 123456789101L, 28, "東京都中央区日本橋1-2-3");
|
||||
car1.color = "赤";
|
||||
car1.gasoline = 50;
|
||||
car1.driverInfo = driver1;
|
||||
|
||||
// 2台目
|
||||
Car car2 = new Car();
|
||||
Driver driver2 = new Driver("佐藤二朗", 109876543210L, 45, "東京都豊島区北池袋1-2-3");
|
||||
car2.color = "黄";
|
||||
car2.gasoline = 60;
|
||||
car2.driverInfo = driver2;
|
||||
|
||||
// 3台目
|
||||
Car car3 = new Car();
|
||||
Driver driver3 = new Driver("鈴木三郎", 101010101010L, 39, "埼玉県さいたま市大宮区錦町1-2-3");
|
||||
car3.color = "青";
|
||||
car3.gasoline = 70;
|
||||
car3.driverInfo = driver3;
|
||||
|
||||
// Car型リストに作成したインスンタンスを格納する
|
||||
List<Car> carList = new ArrayList<>();
|
||||
carList.add(car1);
|
||||
carList.add(car2);
|
||||
carList.add(car3);
|
||||
|
||||
// 配列の要素数分繰り返しを行う
|
||||
for (Car car : carList) {
|
||||
/*
|
||||
* TODO 以下の処理を作成してください
|
||||
* 変数にcar.run()を代入してください 変数にDriver.displayInfo()を代入してください
|
||||
*
|
||||
*/
|
||||
System.out.println("運転手の情報です。");
|
||||
|
||||
/*
|
||||
* TODO 変数に代入した関数displayInfo()を実行してください。
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* 進んだ距離の合計move と runメソッドを実行した回数のcountは繰り返しスコープの外で初期化
|
||||
* このタイミングで初期化をおこなうことで、車ごとの進んだ距離と実行回数にすることができる
|
||||
*/
|
||||
int move = 0;
|
||||
int count = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
/*
|
||||
* carListのi番目のrunメソッドを実行する。 iの数が0,1,2と増えていくので、繰り返すごとに別のインスタンスのrunメソッドが実行される
|
||||
*/
|
||||
/*
|
||||
* TODO 変数に代入した関数run()を実行してください。
|
||||
*
|
||||
*/
|
||||
|
||||
// 戻り値が -1 の時はガソリンがなくなった時なので繰り返し終了
|
||||
if (ret == -1) {
|
||||
System.out.println("目的地に到達できませんでした");
|
||||
break;
|
||||
}
|
||||
|
||||
// 進んだ距離の合計moveにrunメソッドの戻り値を加算
|
||||
move += ret;
|
||||
// runメソッドを実行した回数countをインクリメント
|
||||
count++;
|
||||
|
||||
// 進んだ距離の合計が、目的地を超えた場合は目的についたので繰り返し終了
|
||||
if (DISTANCE <= move) {
|
||||
System.out.println("目的地にまで" + count + "時間かかりました。残りのガソリンは、" + car.gasoline + "リットルです" + "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Question22-FunctionAndLambda/src/PTra22_03.java
Normal file
38
Question22-FunctionAndLambda/src/PTra22_03.java
Normal file
@@ -0,0 +1,38 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/*
|
||||
* PTra22_03.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
/* TODO 関数型インターフェースを作成してから始めてください。
|
||||
* インターフェース名:CalcMultiParamFunc
|
||||
* 抽象メソッド名:CalcMultiParamFunction
|
||||
* ジェネリクス:T
|
||||
* 戻り値の型:int
|
||||
* 引数:T型の引数を3つ
|
||||
*
|
||||
* */
|
||||
public class PTra22_03 {
|
||||
public static void main(String[] args) {
|
||||
List<Integer> array = Arrays.asList(1,2,3,4,5,6,7,8,9);
|
||||
Random rnd = new Random();
|
||||
|
||||
|
||||
System.out.println("計算元の値です");
|
||||
for(Integer number : array) {
|
||||
System.out.print(number + "\t");
|
||||
}
|
||||
int rndNumber1 = rnd.nextInt(9);
|
||||
int rndNumber2 = rnd.nextInt(9);
|
||||
int rndNumber3 = rnd.nextInt(9);
|
||||
System.out.println("\n" + "ランダムに数値を3つ選び足し算します(選ばれた順に足し算します)");
|
||||
/* TODO 作成した関数型インターフェースを使用し、Calc.additionを実行してください
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
}
|
||||
29
Question22-FunctionAndLambda/src/PTra22_04.java
Normal file
29
Question22-FunctionAndLambda/src/PTra22_04.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* PTra22_04.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
public class PTra22_04 {
|
||||
public static void main(String[] args) {
|
||||
List<User> list = new ArrayList<>();
|
||||
User user = new User("田中太郎", "tanaka@hoge,.com", "tanaka@0000");
|
||||
User user2 = new User("鈴木一郎", "suzuki@hoge,.com", "suzuki@1111");
|
||||
User user3 = new User("山田二郎", "yamada@hoge,.com", "yamada@2222");
|
||||
list.add(user);
|
||||
list.add(user2);
|
||||
list.add(user3);
|
||||
|
||||
/*TODO 以下処理を作成してください。
|
||||
* 変数に関数を代入してください。(ラムダ式を使用すること)
|
||||
* ※代入するメソッドはPTra22_01のcreateUsersInfoを使用してください
|
||||
* 関数が代入された変数を実行してください
|
||||
* 取得したリストを表示してください
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
}
|
||||
32
Question22-FunctionAndLambda/src/PTra22_05.java
Normal file
32
Question22-FunctionAndLambda/src/PTra22_05.java
Normal file
@@ -0,0 +1,32 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/*
|
||||
* PTra22_05.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
public class PTra22_05 {
|
||||
public static void main(String[] args) {
|
||||
List<Integer> array = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
Random rnd = new Random();
|
||||
|
||||
System.out.println("計算元の値です");
|
||||
for (Integer number : array) {
|
||||
System.out.print(number + "\t");
|
||||
}
|
||||
int rndNumber1 = rnd.nextInt(9);
|
||||
int rndNumber2 = rnd.nextInt(9);
|
||||
int rndNumber3 = rnd.nextInt(9);
|
||||
System.out.println("\n" + "ランダムに数値を3つ選び足し算します(選ばれた順に足し算します)");
|
||||
/*
|
||||
* TODO 以下処理を作成してください。
|
||||
* x,y,zを足して返却する処理
|
||||
* ラムダ式の省略形を使用して作成してください
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
24
Question22-FunctionAndLambda/src/PTra22_06.java
Normal file
24
Question22-FunctionAndLambda/src/PTra22_06.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* PTra22_06.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
|
||||
import common.Player;
|
||||
import common.PlayerUtill;
|
||||
|
||||
public class PTra22_06 {
|
||||
public static void main(String[] args) {
|
||||
//※ この問題はcommonパッケージのPlayerUtillクラスをよく読んでから解いてください。
|
||||
ArrayList<Player> playerList = PlayerUtill.getPlayerList();
|
||||
|
||||
/* TODO 以下の処理を作成してください。
|
||||
* 選手のリストから、ポジションが FW の選手のみ出力してください
|
||||
* StreamAPIを使用して作成してください
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
}
|
||||
24
Question22-FunctionAndLambda/src/PTra22_07.java
Normal file
24
Question22-FunctionAndLambda/src/PTra22_07.java
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
/*
|
||||
* PTra22_076.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
|
||||
import common.Player;
|
||||
import common.PlayerUtill;
|
||||
|
||||
public class PTra22_07 {
|
||||
public static void main(String[] args) {
|
||||
ArrayList<Player> playerList = PlayerUtill.getPlayerList();
|
||||
|
||||
/* TODO 以下の処理を作成してください。
|
||||
* 選手のリストから、チームがレアル・マドリードでない、バルセロナでない、MFの選手を表示する
|
||||
* StreamAPIを使用して作成してください
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
}
|
||||
31
Question22-FunctionAndLambda/src/PTra22_08.java
Normal file
31
Question22-FunctionAndLambda/src/PTra22_08.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import common.Food;
|
||||
import common.FoodUtill;
|
||||
|
||||
/*
|
||||
* PTra22_08.java
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
public class PTra22_08 {
|
||||
public static void main(String[] args) {
|
||||
// TODO FoodUtillクラスのgetFoodListメソッドを使用して料理一覧を取得してください
|
||||
ArrayList<Food> foodList = FoodUtill.getFoodList();
|
||||
|
||||
/*
|
||||
* TODO 料理一覧の中からランダムに3品選んで、
|
||||
* 選んだ料理名3つと合計の値段を出力してください。
|
||||
* ※ 同じ料理が2回以上表示されてはいけません
|
||||
* ※ 合計金額は 消費税は8%を加算して出力してください。(小数点以下切り捨て)
|
||||
* ※StreamAPIを使用してください
|
||||
*/
|
||||
|
||||
// 料理の一覧をシャッフルする
|
||||
Collections.shuffle(foodList);
|
||||
int threeItems = 3;
|
||||
|
||||
}
|
||||
}
|
||||
35
Question22-FunctionAndLambda/src/User.java
Normal file
35
Question22-FunctionAndLambda/src/User.java
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
public class User {
|
||||
private String user;
|
||||
private String mail;
|
||||
private String pass;
|
||||
|
||||
public User(String user, String mail, String pass) {
|
||||
this.user = user;
|
||||
this.mail = mail;
|
||||
this.pass = pass;
|
||||
}
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
public String getMail() {
|
||||
return mail;
|
||||
}
|
||||
public void setMail(String mail) {
|
||||
this.mail = mail;
|
||||
}
|
||||
public String getPass() {
|
||||
return pass;
|
||||
}
|
||||
public void setPass(String pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "名前:" + this.user + "\t" + "メールアドレス:" + this.mail + "\t" + "パスワード:" + this.pass;
|
||||
}
|
||||
|
||||
}
|
||||
36
Question22-FunctionAndLambda/src/common/Food.java
Normal file
36
Question22-FunctionAndLambda/src/common/Food.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package common;
|
||||
|
||||
public class Food {
|
||||
|
||||
// 名前
|
||||
String name;
|
||||
|
||||
// 値段
|
||||
int price;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(int price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Food(String name, int price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
35
Question22-FunctionAndLambda/src/common/FoodUtill.java
Normal file
35
Question22-FunctionAndLambda/src/common/FoodUtill.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class FoodUtill {
|
||||
|
||||
/**
|
||||
* fileの中のFoodMenu.csvを読み込んで、
|
||||
* ArrayList<Food>の形に変換して返す
|
||||
* @return 料理一覧
|
||||
*/
|
||||
public static ArrayList<Food> getFoodList() {
|
||||
ArrayList<Food> foodList = new ArrayList<>();
|
||||
try (Scanner scanner = new Scanner(new File("file/FoodMenu.csv"))) {
|
||||
while(scanner.hasNext()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] input = line.split(",");
|
||||
Food player = new Food(input[0],Integer.parseInt(input[1]));
|
||||
foodList.add(player);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("ファイルが見つかりません");
|
||||
}
|
||||
return foodList;
|
||||
}
|
||||
|
||||
}
|
||||
109
Question22-FunctionAndLambda/src/common/Player.java
Normal file
109
Question22-FunctionAndLambda/src/common/Player.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package common;
|
||||
|
||||
public class Player {
|
||||
/** ポジション */
|
||||
private String position;
|
||||
|
||||
/** 名前 */
|
||||
private String name;
|
||||
|
||||
/** 国 */
|
||||
private String country;
|
||||
|
||||
/** 所属チーム */
|
||||
private String team;
|
||||
|
||||
public Player() {
|
||||
|
||||
}
|
||||
|
||||
public Player(String position, String name, String country, String team) {
|
||||
this.position = position;
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
/**
|
||||
* ポジションを取得します
|
||||
* @return ポジション
|
||||
*/
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
/**
|
||||
* ポジションを設定します
|
||||
* @param position 設定したいポジション
|
||||
*/
|
||||
public void setPosition(String position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* 名前を取得します
|
||||
* @return 名前
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 名前を設定します
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 国を取得します
|
||||
* @return
|
||||
*/
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
/**
|
||||
* 国を設定します
|
||||
* @param country 設定したい国
|
||||
*/
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属チームを取得します
|
||||
* @return 所属チーム
|
||||
*/
|
||||
public String getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属チームを設定します
|
||||
* @param team 設定したい所属チーム
|
||||
*/
|
||||
public void setTeam(String team) {
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
final String SEP = ",";
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(this.position);
|
||||
str.append(SEP);
|
||||
str.append(this.name);
|
||||
str.append(SEP);
|
||||
str.append(this.country);
|
||||
str.append(SEP);
|
||||
str.append(this.team);
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
35
Question22-FunctionAndLambda/src/common/PlayerUtill.java
Normal file
35
Question22-FunctionAndLambda/src/common/PlayerUtill.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class PlayerUtill {
|
||||
|
||||
/**
|
||||
* fileの中のBestElevenCandidate.csvを読み込んで、
|
||||
* ArrayList<Player>の形に変換して返す
|
||||
* @return サッカー選手一覧
|
||||
*/
|
||||
public static ArrayList<Player> getPlayerList() {
|
||||
ArrayList<Player> playerList = new ArrayList<>();
|
||||
try (Scanner scanner = new Scanner(new File("file/BestElevenCandidate.csv"))) {
|
||||
while(scanner.hasNext()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] input = line.split(",");
|
||||
Player player = new Player(input[0],input[1],input[2],input[3]);
|
||||
playerList.add(player);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("ファイルが見つかりません");
|
||||
}
|
||||
return playerList;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user