アットウィキロゴ

ArrayTest問題

import java.util.ArrayList;
import java.io.*;
 
public class ArrayTestName {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int command;
		ArrayList<???> list = new ArrayList<???>();
 
		do {
			command = getCommand();
 
			switch (???){
			case 1:
 
				try {
					System.out.println("名前を入力してください");
					String line = ???;
					list.add(line);
					System.out.println(line + "さんを登録しました。");
				} catch (IOException e){
			  		System.out.println(e);
				}
				break;
			case 2:
				System.out.println("一覧を表示します。");
				for (int i = 0; i < ???; i++){
					System.out.println(???);
				}
				break;
			}
		} while (command != 0);
 
		System.out.println("終了します。");
    }
	/* 操作画面を表示して入力を受け取る */
	static int getCommand(){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int command = 0;
 
		try {
			System.out.println("操作を選んで下さい");
			System.out.println("1.登録");
			System.out.println("2.一覧確認");
			System.out.println("0.終了");
 
			String line = ???;
			command = Integer.parseInt(line);
		} catch (IOException e){
			System.out.println(e);
		}
 
 
		return command;
	}
}

タグ:

+ タグ編集
  • タグ:
最終更新:2012年02月07日 09:13