diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales02.java b/java-learning/src/jp/co/jid/exec/collection/Sales02.java new file mode 100644 index 0000000..ffef790 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales02.java @@ -0,0 +1,36 @@ +package jp.co.jid.exec.collection; + +public class Sales02 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + + // 1月から6月の売上 + // 0の月は営業していない + // 月毎に店舗IDの順番で設定されている + private int[][] sales = { + {550, 380, 980, 0, 280, 540, 700, 110, 650, 680, 980, 460}, + {500, 400, 1020, 0, 270, 600, 650, 100, 600, 640, 970, 400}, + {550, 390, 900, 0, 260, 550, 600, 120, 630, 640, 960, 450}, + {520, 410, 950, 1050, 270, 530, 620, 160, 660, 630, 970, 473}, + {600, 300, 1020, 1010, 220, 480, 680, 150, 630, 630, 975, 477}, + {480, 320, 900, 1000, 255, 650, 680, 0, 650, 620, 985, 465}, + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[][] getSales() { + return sales; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales02.java b/java-learning/src/jp/co/jid/exec/collection/Sales02.java new file mode 100644 index 0000000..ffef790 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales02.java @@ -0,0 +1,36 @@ +package jp.co.jid.exec.collection; + +public class Sales02 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + + // 1月から6月の売上 + // 0の月は営業していない + // 月毎に店舗IDの順番で設定されている + private int[][] sales = { + {550, 380, 980, 0, 280, 540, 700, 110, 650, 680, 980, 460}, + {500, 400, 1020, 0, 270, 600, 650, 100, 600, 640, 970, 400}, + {550, 390, 900, 0, 260, 550, 600, 120, 630, 640, 960, 450}, + {520, 410, 950, 1050, 270, 530, 620, 160, 660, 630, 970, 473}, + {600, 300, 1020, 1010, 220, 480, 680, 150, 630, 630, 975, 477}, + {480, 320, 900, 1000, 255, 650, 680, 0, 650, 620, 985, 465}, + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[][] getSales() { + return sales; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/Shop01.java b/java-learning/src/jp/co/jid/exec/collection/Shop01.java new file mode 100644 index 0000000..aa8421b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Shop01.java @@ -0,0 +1,38 @@ +package jp.co.jid.exec.collection; + +import java.util.HashMap; + +public class Shop01 { + + // 店舗名 + private HashMap names = new HashMap() { + { + put("A01", "本部"); + put("A02", "博多店"); + put("A03", "箱崎店"); + put("A04", "香椎店"); + put("A05", "小倉店"); + put("A06", "門司店"); + put("A07", "大野城店"); + put("A08", "大宰府店"); + put("A09", "小郡店"); + put("A10", "久留米店"); + put("A11", "朝倉店"); + put("A12", "大牟田店"); + } + }; + + /** + * キーから店舗名を取得 + * 存在しない場合は、「店舗無」を返却 + * @param key + * @return + */ + public String getName(String key) { + if (!names.containsKey(key)) { + return "店舗無"; + } + return names.get(key); + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales02.java b/java-learning/src/jp/co/jid/exec/collection/Sales02.java new file mode 100644 index 0000000..ffef790 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales02.java @@ -0,0 +1,36 @@ +package jp.co.jid.exec.collection; + +public class Sales02 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + + // 1月から6月の売上 + // 0の月は営業していない + // 月毎に店舗IDの順番で設定されている + private int[][] sales = { + {550, 380, 980, 0, 280, 540, 700, 110, 650, 680, 980, 460}, + {500, 400, 1020, 0, 270, 600, 650, 100, 600, 640, 970, 400}, + {550, 390, 900, 0, 260, 550, 600, 120, 630, 640, 960, 450}, + {520, 410, 950, 1050, 270, 530, 620, 160, 660, 630, 970, 473}, + {600, 300, 1020, 1010, 220, 480, 680, 150, 630, 630, 975, 477}, + {480, 320, 900, 1000, 255, 650, 680, 0, 650, 620, 985, 465}, + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[][] getSales() { + return sales; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/Shop01.java b/java-learning/src/jp/co/jid/exec/collection/Shop01.java new file mode 100644 index 0000000..aa8421b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Shop01.java @@ -0,0 +1,38 @@ +package jp.co.jid.exec.collection; + +import java.util.HashMap; + +public class Shop01 { + + // 店舗名 + private HashMap names = new HashMap() { + { + put("A01", "本部"); + put("A02", "博多店"); + put("A03", "箱崎店"); + put("A04", "香椎店"); + put("A05", "小倉店"); + put("A06", "門司店"); + put("A07", "大野城店"); + put("A08", "大宰府店"); + put("A09", "小郡店"); + put("A10", "久留米店"); + put("A11", "朝倉店"); + put("A12", "大牟田店"); + } + }; + + /** + * キーから店舗名を取得 + * 存在しない場合は、「店舗無」を返却 + * @param key + * @return + */ + public String getName(String key) { + if (!names.containsKey(key)) { + return "店舗無"; + } + return names.get(key); + } +} + diff --git a/java-learning/src/jp/co/jid/exec/etc/Human.java b/java-learning/src/jp/co/jid/exec/etc/Human.java new file mode 100644 index 0000000..6d1719c --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/etc/Human.java @@ -0,0 +1,19 @@ +package jp.co.jid.exec.etc; + +public class Human { + private String name; + private int age; + + Human(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales02.java b/java-learning/src/jp/co/jid/exec/collection/Sales02.java new file mode 100644 index 0000000..ffef790 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales02.java @@ -0,0 +1,36 @@ +package jp.co.jid.exec.collection; + +public class Sales02 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + + // 1月から6月の売上 + // 0の月は営業していない + // 月毎に店舗IDの順番で設定されている + private int[][] sales = { + {550, 380, 980, 0, 280, 540, 700, 110, 650, 680, 980, 460}, + {500, 400, 1020, 0, 270, 600, 650, 100, 600, 640, 970, 400}, + {550, 390, 900, 0, 260, 550, 600, 120, 630, 640, 960, 450}, + {520, 410, 950, 1050, 270, 530, 620, 160, 660, 630, 970, 473}, + {600, 300, 1020, 1010, 220, 480, 680, 150, 630, 630, 975, 477}, + {480, 320, 900, 1000, 255, 650, 680, 0, 650, 620, 985, 465}, + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[][] getSales() { + return sales; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/Shop01.java b/java-learning/src/jp/co/jid/exec/collection/Shop01.java new file mode 100644 index 0000000..aa8421b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Shop01.java @@ -0,0 +1,38 @@ +package jp.co.jid.exec.collection; + +import java.util.HashMap; + +public class Shop01 { + + // 店舗名 + private HashMap names = new HashMap() { + { + put("A01", "本部"); + put("A02", "博多店"); + put("A03", "箱崎店"); + put("A04", "香椎店"); + put("A05", "小倉店"); + put("A06", "門司店"); + put("A07", "大野城店"); + put("A08", "大宰府店"); + put("A09", "小郡店"); + put("A10", "久留米店"); + put("A11", "朝倉店"); + put("A12", "大牟田店"); + } + }; + + /** + * キーから店舗名を取得 + * 存在しない場合は、「店舗無」を返却 + * @param key + * @return + */ + public String getName(String key) { + if (!names.containsKey(key)) { + return "店舗無"; + } + return names.get(key); + } +} + diff --git a/java-learning/src/jp/co/jid/exec/etc/Human.java b/java-learning/src/jp/co/jid/exec/etc/Human.java new file mode 100644 index 0000000..6d1719c --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/etc/Human.java @@ -0,0 +1,19 @@ +package jp.co.jid.exec.etc; + +public class Human { + private String name; + private int age; + + Human(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } +} diff --git a/java-learning/src/jp/co/jid/exec/etc/NameUtil.java b/java-learning/src/jp/co/jid/exec/etc/NameUtil.java new file mode 100644 index 0000000..0696295 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/etc/NameUtil.java @@ -0,0 +1,21 @@ +package jp.co.jid.exec.etc; + +public class NameUtil { + + private static final String DATA = + "あいうえおかきくけこさしすせそたちつてとなにぬねの" + + "はひふへほやゆよらりるれろわんがぎぐげござじずぜぞ" + + "だぢづでどばびぷぺぼぱぴぷぺぽ"; + private static final int DATALEN = DATA.length(); + + public static String createName() { + int len = (int)(Math.random() * 4) + 3; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < len; i++) { + int pt = (int)(Math.random() * DATALEN); + sb.append(DATA.substring(pt, pt + 1)); + } + return sb.toString(); + } + +} diff --git a/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java new file mode 100644 index 0000000..7f1090b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputNumberUtil.java @@ -0,0 +1,32 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputNumberUtil { + + public static int[] input(int num) { + System.out.println("数字を入力して下さい。"); + BufferedReader br = null; + int values[] = new int[num]; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + for (int i = 0; i < num;i++) { + values[i] = Integer.parseInt(br.readLine()); + } + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + return values; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/InputUtil.java b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java new file mode 100644 index 0000000..f0ee6a0 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/InputUtil.java @@ -0,0 +1,28 @@ +package jp.co.jid.exec.collection; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class InputUtil { + + public static String input() { + System.out.println("文字を入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + return br.readLine(); + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales01.java b/java-learning/src/jp/co/jid/exec/collection/Sales01.java new file mode 100644 index 0000000..2fc6700 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales01.java @@ -0,0 +1,29 @@ +package jp.co.jid.exec.collection; + +public class Sales01 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + // 売上一覧 + private int[] sales = { + 550, 380, 980, 1010, 280, 540, 680, 110, 650, 680, 980, 460 + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[] getSales() { + return sales; + } +} + diff --git a/java-learning/src/jp/co/jid/exec/collection/Sales02.java b/java-learning/src/jp/co/jid/exec/collection/Sales02.java new file mode 100644 index 0000000..ffef790 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Sales02.java @@ -0,0 +1,36 @@ +package jp.co.jid.exec.collection; + +public class Sales02 { + // 店舗ID一覧 + private String[] shops = { + "A10", "A09", "A02", "A01", "A05","A11", + "A07", "A08", "A04", "A06", "A03","A12" + }; + + // 1月から6月の売上 + // 0の月は営業していない + // 月毎に店舗IDの順番で設定されている + private int[][] sales = { + {550, 380, 980, 0, 280, 540, 700, 110, 650, 680, 980, 460}, + {500, 400, 1020, 0, 270, 600, 650, 100, 600, 640, 970, 400}, + {550, 390, 900, 0, 260, 550, 600, 120, 630, 640, 960, 450}, + {520, 410, 950, 1050, 270, 530, 620, 160, 660, 630, 970, 473}, + {600, 300, 1020, 1010, 220, 480, 680, 150, 630, 630, 975, 477}, + {480, 320, 900, 1000, 255, 650, 680, 0, 650, 620, 985, 465}, + }; + + /** + * 店舗一覧を返す + * @return + */ + public String[] getShops() { + return shops; + } + /** + * 売上一覧を返す + * @return + */ + public int[][] getSales() { + return sales; + } +} diff --git a/java-learning/src/jp/co/jid/exec/collection/Shop01.java b/java-learning/src/jp/co/jid/exec/collection/Shop01.java new file mode 100644 index 0000000..aa8421b --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/collection/Shop01.java @@ -0,0 +1,38 @@ +package jp.co.jid.exec.collection; + +import java.util.HashMap; + +public class Shop01 { + + // 店舗名 + private HashMap names = new HashMap() { + { + put("A01", "本部"); + put("A02", "博多店"); + put("A03", "箱崎店"); + put("A04", "香椎店"); + put("A05", "小倉店"); + put("A06", "門司店"); + put("A07", "大野城店"); + put("A08", "大宰府店"); + put("A09", "小郡店"); + put("A10", "久留米店"); + put("A11", "朝倉店"); + put("A12", "大牟田店"); + } + }; + + /** + * キーから店舗名を取得 + * 存在しない場合は、「店舗無」を返却 + * @param key + * @return + */ + public String getName(String key) { + if (!names.containsKey(key)) { + return "店舗無"; + } + return names.get(key); + } +} + diff --git a/java-learning/src/jp/co/jid/exec/etc/Human.java b/java-learning/src/jp/co/jid/exec/etc/Human.java new file mode 100644 index 0000000..6d1719c --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/etc/Human.java @@ -0,0 +1,19 @@ +package jp.co.jid.exec.etc; + +public class Human { + private String name; + private int age; + + Human(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } +} diff --git a/java-learning/src/jp/co/jid/exec/etc/NameUtil.java b/java-learning/src/jp/co/jid/exec/etc/NameUtil.java new file mode 100644 index 0000000..0696295 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/etc/NameUtil.java @@ -0,0 +1,21 @@ +package jp.co.jid.exec.etc; + +public class NameUtil { + + private static final String DATA = + "あいうえおかきくけこさしすせそたちつてとなにぬねの" + + "はひふへほやゆよらりるれろわんがぎぐげござじずぜぞ" + + "だぢづでどばびぷぺぼぱぴぷぺぽ"; + private static final int DATALEN = DATA.length(); + + public static String createName() { + int len = (int)(Math.random() * 4) + 3; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < len; i++) { + int pt = (int)(Math.random() * DATALEN); + sb.append(DATA.substring(pt, pt + 1)); + } + return sb.toString(); + } + +} diff --git a/java-learning/src/jp/co/jid/exec/exception/InputUtil.java b/java-learning/src/jp/co/jid/exec/exception/InputUtil.java new file mode 100644 index 0000000..f77dbf3 --- /dev/null +++ b/java-learning/src/jp/co/jid/exec/exception/InputUtil.java @@ -0,0 +1,43 @@ +package jp.co.jid.exec.exception; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class InputUtil { + + public static ArrayList input() { + System.out.println("数値をカンマ区切りで入力して下さい。"); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(System.in)); + String inputStr = br.readLine(); + String[] splitStr = inputStr.split(","); + ArrayList strList = new ArrayList(); + if (splitStr.length == 0) { + strList.add(null); + strList.add(null); + } + else if (splitStr.length == 1) { + strList.add(splitStr[0].isEmpty() ? null : splitStr[0]); + strList.add(null); + } + else { + strList.add(splitStr[0].isEmpty() ? null : splitStr[0]); + strList.add(splitStr[1].isEmpty() ? null : splitStr[1]); + } + return strList; + } catch (IOException e) { + return null; + } finally { + if (null != br) { + try { + br.close(); + } catch (IOException e) { + // 未処理 + } + } + } + } +} \ No newline at end of file