为使更好的面向对象,在工具类里面封装了一些简单的方法 package com.xll.util;import com.xll.model.*;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileInputStream;imp
package com.xll.util; import com.xll.model.*; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.*; import com.xll.manage.Menu; public class Tools { static Scanner input=new Scanner(System.in); public static void pl(String arg){ System.out.println(arg); } public static void p(String arg){ System.out.println(arg); } public static void pl(Object arg){ System.out.println(arg); } public static String getString(String str){ pl(str); return input.next(); } public static int getInt(int str){ pl(str); try { Scanner input=new Scanner(System.in); return input.nextInt(); } catch (Exception e) { // TODO: handle exception pl("请输入合法数字"); return 100; } } public static int getInt(String str){ pl(str); try { Scanner input=new Scanner(System.in); return input.nextInt(); } catch (Exception e) { // TODO: handle exception pl("请输入合法数字"); return 100; } } public static String select(String s){ pl(s); String str=""; while(true){ String temp=input.next(); if(temp.equalsIgnoreCase("n")||temp.equalsIgnoreCase("y")||temp.equalsIgnoreCase("是")||temp.equalsIgnoreCase("否")){ str=temp; break; } else pl("输入错误,请重新输入"); } return str; } public static boolean isContinue(String str){ if(select(str).equalsIgnoreCase("n")) return false; else return true; } //菜单生成器 public static int menuFactory(String msg){ String[] strs=msg.split(","); StringBuffer sb=new StringBuffer(); sb.append("--------------------------------------\n"); for (int i=0;i