1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.io.BufferedReader ; 4 import java.io.IOException ; 5 import java.io.InputStreamReader ; 6 7 8 public class Interactive { 9 static BufferedReader input; 10 11 static { 12 input = new BufferedReader (new InputStreamReader (System.in)); 13 } 14 15 16 static public String readLine() throws IOException { 17 return input.readLine(); 18 } 19 20 21 static public void writeLine(String line) { 22 Output.out.println(line); 23 } 24 25 26 static public void write(String line) { 27 Output.out.print(line); 28 } 29 30 31 static public boolean askYesNo(String message, boolean strong, String strongMessage) { 32 try { 33 System.out.print(message+" (y/N): "); 34 String answer = input.readLine(); 35 answer = answer.trim(); 36 if (answer.compareTo("")==0) 37 return false; 38 if (answer.compareTo("y")==0) { 39 if (strong) { 40 System.out.print(strongMessage+" (y/N): "); 41 answer = input.readLine(); 42 answer = answer.trim(); 43 if (answer.compareTo("")==0) 44 return false; 45 if (answer.compareTo("y")==0) 46 return true; 47 return false; 48 } 49 return true; 50 } 51 return false; 52 } catch (IOException e) { 53 return false; 54 } 55 } 56 } 57 | Popular Tags |