init
This commit is contained in:
36
Question19-Collection/src/common/Food.java
Normal file
36
Question19-Collection/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
Question19-Collection/src/common/FoodUtill.java
Normal file
35
Question19-Collection/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
Question19-Collection/src/common/Player.java
Normal file
109
Question19-Collection/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
Question19-Collection/src/common/PlayerUtill.java
Normal file
35
Question19-Collection/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