・・・ |
|
|
012 |
|
public class KCEMain { |
013 |
|
|
014 |
|
//******************************************** |
015 |
|
// 定数 |
016 |
|
//******************************************** |
017 |
|
|
018 |
|
//******************************************** |
019 |
|
// 変数 |
020 |
|
//******************************************** |
021 |
|
private static int inputNum = 0;//入力番号 |
022 |
|
|
023 |
|
/** |
024 |
|
* @param args the command line arguments |
025 |
|
*/ |
026 |
|
public static void main(String[] args) { |
027 |
|
// TODO code application logic here |
028 |
|
|
029 |
|
//******************************************** |
030 |
|
//
メイン処理 |
031 |
|
//******************************************** |
032 |
|
boolean loopFlg =
true;//ループフラグ |
033 |
|
|
034 |
|
while (loopFlg ) { |
035 |
|
|
036 |
|
System.out.print(">");
//テスト用:表示確認 |
037 |
|
|
038 |
|
//キー入力処理 |
039 |
|
inputNum = scanInputData(); |
040 |
|
|
041 |
|
System.out.println("入力テスト:"
+ inputNum );//テスト用:表示確認 |
042 |
|
|
043 |
|
//表示開始の区切り |
044 |
|
printSeparateMark(); |
045 |
|
} |
046 |
|
|
047 |
|
} |
048 |
|
|
049 |
|
/** |
050 |
|
* キー入力処理 |
051 |
|
*/ |
052 |
|
private static int scanInputData() { |
053 |
|
|
054 |
|
///////////////////////////////////////////////////// |
055 |
|
//キー入力処理 そのまま書き写してください ここから |
056 |
|
int
tmpInputNum = 0;//入力番号初期化 |
057 |
|
while (true) { |
058 |
|
try { |
059 |
|
//初期化処理 |
060 |
|
final int IMPUT_MAX = 5;//最大入力値 |
061 |
|
//キー入力読込処理(int型) |
062 |
|
java.util.Scanner sc =
new
java.util.Scanner(System.in); |
063 |
|
int inputInt = sc.nextInt(); |
064 |
|
//入力値チェックと入力番号への代入 |
065 |
|
if (inputInt > 0 && inputInt <= IMPUT_MAX) { |
066 |
|
tmpInputNum = inputInt; |
067 |
|
break; |
068 |
|
}
else { |
069 |
|
System.out.println("※ コマンドは" + IMPUT_MAX +
"以下で入力して下さい ※ "); |
070 |
|
System.out.print(">"); |
071 |
|
} |
072 |
|
}
catch (Exception e) { |
073 |
|
System.out.println("※ 数字以外は入力しないで下さい ※ "); |
074 |
|
System.out.print(">"); |
075 |
|
} |
076 |
|
} |
077 |
|
//キー入力処理 そのまま書き写してください ここまで |
078 |
|
///////////////////////////////////////////////////// |
079 |
|
|
080 |
|
//入力番号を返す |
081 |
|
return tmpInputNum; |
082 |
|
} |
083 |
|
|
084 |
|
/** |
085 |
|
* 区切り処理 |
086 |
|
*/ |
087 |
|
private static void printSeparateMark() { |
088 |
|
//表示終了の区切り |
089 |
|
System.out.println(""); |
090 |
|
System.out.println("######################################################"); |
091 |
|
System.out.println(""); |
092 |
|
} |
093 |
|
|
094 |
|
} |
・・・ |
|
|