📄 inputcheak.java
字号:
import javax.swing.JOptionPane;class InputCheak{ private boolean boolUserWantMoreCalculation; private boolean boolUserNeedThisLogicGate; private int intErrorInputRecord; private String strMoreCalculate; private String strWhatKindofOption; private String strWhatKindofCalculate; private String strUserChoise; public void UserStartProgramCheak(){ intErrorInputRecord = 0; //set variable intErrorInputRecord = 0 while (intErrorInputRecord < 3) { JOptionPane.showMessageDialog(null, "Do you want to do a logic calculation?"+ "\n\n" + "YES = 1 : please input (SINGLE Figure) 1 (NO space)" + "\n" + "NO & Exit = 0 : please input (SINGLE Figure) 0 (NO space)" + "\n"); System.out.println("Do you want to do a logic calculation?"+ "\n\n" + "YES : please input (SINGLE Figure) 1 (NO space)" + "\n" + "NO & Exit = 0: please input (SINGLE Figure) 0 (NO space)" + "\n"); InputData userInput = new InputData(); //get input and save input string to strMoreCalculate strMoreCalculate = userInput.GetKeyboardInput(); if (!(strMoreCalculate.equals("0")) & !(strMoreCalculate.equals("1"))) { JOptionPane.showMessageDialog(null, "Your input is: "+ strMoreCalculate + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" +"1 (1=YES)" + "\n" + "0 (0=NO & Exit)"+"\n"); System.out.println("Your input is: "+ strMoreCalculate + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" +"1 (1=YES)" + "\n" + "0 (0=NO & Exit)"+"\n"); intErrorInputRecord++; } //end of if() if (strMoreCalculate.equals("0")) { JOptionPane.showMessageDialog(null, "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.out.println( "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.exit(0); } //end of if() if (strMoreCalculate.equals("1")) { intErrorInputRecord=5; //quit loop method: while(intErrorInputRecord < 3) //by giving value 5(>3) to variable intErrorInputRecord = 5 } //end of if() if (intErrorInputRecord == 3) { JOptionPane.showMessageDialog(null, "You input wrong figure for 3 times!" +"\n\n" + "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.exit(0); } //end of if() } //end of while(intErrorInputRecord < 3) //while(intErrorInputRecord < 3) is cheaking to calculate or not to calculate here } //end of UserStartProgramCheak( public void UserWantMoreCalculationCheak(){ boolUserWantMoreCalculation = false; while (!(boolUserWantMoreCalculation)) { /******************************************************************************************************************* * * ******************************************************************************************************************/ intErrorInputRecord = 0; //reset variable intErrorInputRecord = 0 while (intErrorInputRecord<3) { JOptionPane.showMessageDialog(null, "What do you want to do now?"+ "\n\n" + "Please Choose the following options:" + "\n" + "Please ONLY input SINGLE Figure(NO space): " + "\n\n" + "1 = Use the Result of last calculation to start another calculation" + "\n" + "5 = Start a new calculation without the Result of last calculation" + "\n\n" + "0 = Exit" + "\n"); System.out.println( "*******************************************************************" + "\n\n" + "What do you want to do now?"+ "\n\n" + "Please Choose the following options:" + "\n" + "Please ONLY input SINGLE Figure(NO space): " + "\n\n" + "1 = Use the Result of last calculation to start another calculation" + "\n" + "5 = Start a new calculation without the Result of last calculation" + "\n\n" + "0 = Exit" + "\n"); InputData userInput = new InputData(); //get input and save input string to strMoreCalculate strMoreCalculate = userInput.GetKeyboardInput(); if (!(strMoreCalculate.equals("0")) & !(strMoreCalculate.equals("1")) & !(strMoreCalculate.equals("5"))) { JOptionPane.showMessageDialog(null, "Your input is: "+ strMoreCalculate + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" + "1 = Use the Result of last calculation to start another calculation" + "\n" + "5 = Start a new calculation without the Result of last calculation" + "\n\n" + "0 = Exit" + "\n"); System.out.println("Your input is: "+ strMoreCalculate + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" + "1 = Use the Result of last calculation to start another calculation" + "\n" + "5 = Start a new calculation without the Result of last calculation" + "\n\n" + "0 = Exit" + "\n"); intErrorInputRecord++; } //end of if() if (strMoreCalculate.equals("0")) { JOptionPane.showMessageDialog(null, "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.out.println( "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.exit(0); } //end of if() if (strMoreCalculate.equals("1")) { intErrorInputRecord=5; //quit loop method: while(intErrorInputRecord < 3) //by giving value 5(>3) to variable intErrorInputRecord = 5 } //end of if() if (strMoreCalculate.equals("5")) { intErrorInputRecord=5; //quit loop method: while(intErrorInputRecord < 3) //by giving value 5(>3) to variable intErrorInputRecord = 5 } //end of if() if (intErrorInputRecord == 3) { JOptionPane.showMessageDialog(null, "You input wrong figure for 3 times!" +"\n\n" + "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.exit(0); } //end of if() } //end of loop method: while(intErrorInputRecord < 3) /******************************************************************************************************************* * * ******************************************************************************************************************/ if (strMoreCalculate.equals("1")) { strUserChoise = "1 = Use the Result of last calculation to start another calculation"; } //end of if() if (strMoreCalculate.equals("5")) { strUserChoise = "5 = Start a new calculation without the Result of last calculation"; } //end of if() intErrorInputRecord = 0; //reset variable intErrorInputRecord = 0 while (intErrorInputRecord < 3) { JOptionPane.showMessageDialog(null, "You have chosen the following option: "+ "\n" + strUserChoise + "\n\n" + "Is it what you want?" + "\n" + "Please Confirm by choosing the following options" + "\n" + "Please input SINGLE Figure (NO space):"+ "\n\n" + "1 = YES, Its what i want" + "\n" + "5 = NO, Its NOT what i want, i wanna CHOOSE AGAIN" + "\n" + "0 = Exit program"+ "\n"); System.out.println("You have chosen the following option: "+ "\n" + strUserChoise + "\n\n" + "Is it what you want?" +"\n" + "Please Confirm by choosing the following options" + "\n" + "Please input SINGLE Figure (NO space):"+ "\n\n" + "1 = YES, Its what i want" + "\n" + "5 = NO, Its NOT what i want, i wanna CHOOSE AGAIN" + "\n" + "0 = Exit program"+ "\n"); InputData userInput = new InputData(); //get user input and save input string to strstrWhatKindofOption strWhatKindofOption = userInput.GetKeyboardInput(); if (!(strWhatKindofOption.equals("0")) & !(strWhatKindofOption.equals("1")) & !(strWhatKindofOption.equals("5"))) { JOptionPane.showMessageDialog(null, "Your input is: "+ strWhatKindofOption + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" + "1 = YES, Its what i want" + "\n" + "5 = NO, Its NOT what i want, i wanna CHOOSE AGAIN" + "\n\n" + "0 = Exit program"+ "\n"); System.out.println("Your input is: "+ strWhatKindofOption + "\n\n" + "Please ONLY input SINGLE Figure (NO space):"+"\n\n" + "1 = YES, Its what i want" + "\n" + "5 = NO, Its NOT what i want, i wanna CHOOSE AGAIN" + "\n\n" + "0 = Exit program"+ "\n"); intErrorInputRecord++; } //end of if() if (strWhatKindofOption.equals("0")) { JOptionPane.showMessageDialog(null, "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" + "For more information please visit:" + "\n" + "http://java.sun.com" +"\n\n" + "Program TERMINATE" + "\n"); System.out.println( "Thank you for use this program!"+ "\n\n" + "Program provided by: Mr ZHU Xing Jin" +"\n" + "Student of University of Center Lancashire" + "\n" + "Program based on: JAVA Technology" + "\n\n" + "JAVA is a registered Trade Mark of Sun Micorsystems" + "\n" +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -