日期:2014-05-20 浏览次数:20984 次
public BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public int showHandle() throws IOException { showWelcome(); System.out.println(" **********请输入您要的操作**********\n"); System.out.println(" 1 存款"); System.out.println(" 2 取款"); System.out.println(" 3 显示余额"); System.out.println(" 4 修改密码"); System.out.println(" 5 退出\n"); for (count = 0; count < 3; count++) { System.out.print(" 请输入操作:"); try { choose = Integer.parseInt(br.readLine());}catch(IOException ioe){ioe.printStackTrace();} if (choose != 1 && choose != 2 && choose != 3 && choose != 4 && choose != 5) { showWelcome(); System.out.println("\n\n XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); System.out.println(" XXX 您的输入有误! XXX"); System.out.println(" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"); } else { return choose; } } br.close(); return 0; }
import java.io.*; public class Test { public BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); protected void showWelcome() { System.out.println(" Welcome my testing "); } protected int choose; public int showHandle() throws IOException { showWelcome(); System.out.println(" **********请输入您要的操作**********\n"); System.out.println(" 1 存款"); System.out.println(" 2 取款"); System.out.println(" 3 显示余额"); System.out.println(" 4 修改密码"); System.out.println(" 5 退出\n"); for (int count = 0; count < 3; count++) { System.out.print(" 请输入操作:"); try { choose = Integer.parseInt(br.readLine()); } catch (IOException ioe) { ioe.printStackTrace(); } if (choose != 1 && choose != 2 && choose != 3 && choose != 4 && choose != 5) { showWelcome(); System.out.println("\n\n XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); System.out.println(" XXX 您的输入有误! XXX"); System.out.println(" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"); } else { return choose; } } br.close(); return 0; } public static void main(String[] args) throws Exception { Test test = new Test(); test.showHandle(); } }