Don't say much , Direct code .

one , Let's start with a few tools .

1, Input operation restricted tool class (TSUtility)
package MathDemo; import java.util.Random; import java.util.Scanner; import
java.util.regex.Pattern; public class TSUtility { private static Scanner
scanner = new Scanner(System.in); public static char readMenuSelection() { char
c; for (; ; ) { String str = readKeyBoard(1, false); c = str.charAt(0); if (c
!= '1' && c != '2' && c != '3' && c != '4') { System.out.print(" Selection error , Please re-enter :");
} else break; } return c; } public static char readMenuSelectionPro() { char c;
for (; ; ) { String str = readKeyBoard(1, false); c = str.charAt(0); if (c !=
'1' && c != '2' && c != '3' && c != '4' && c != '5') {
System.out.print(" Selection error , Please re-enter :"); } else break; } return c; } public static void
readReturn() { System.out.print(" press Enter to continue ..."); readKeyBoard(100, true); } public
static int readInt() { int n; for (; ; ) { String str = readKeyBoard(2, false);
try { n = Integer.parseInt(str); break; } catch (NumberFormatException e) {
System.out.print(" Digital input error , Please re-enter :"); } } return n; } public static int
readstock() { int n; for (; ; ) { String str = readKeyBoard(6, false); try { n
= Integer.parseInt(str); break; } catch (NumberFormatException e) {
System.out.print(" Digital input error , Please re-enter :"); } } return n; } public static Double
readDouble() { Double n; for (; ; ) { String str = readKeyBoard(6, false); try
{ n = Double.parseDouble(str); break; } catch (NumberFormatException e) {
System.out.print(" Digital input error , Please re-enter :"); } } return n; } public static char
readConfirmSelection() { char c; for (; ; ) { String str = readKeyBoard(1,
false).toUpperCase(); c = str.charAt(0); if (c == 'Y' || c == 'N') { break; }
else { System.out.print(" Selection error , Please re-enter :"); } } return c; } public static String
readString(int limit, String defaultValue) { String str = readKeyBoard(limit,
true); return str.equals("") ? defaultValue : str; } public static String
readKeyBoard(int limit, boolean blankReturn) { String line = ""; while
(scanner.hasNextLine()) { line = scanner.nextLine(); if (line.length() == 0) {
if (blankReturn) return line; else continue; } if (line.length() < 1 ||
line.length() > limit) { System.out.print(" Input length ( Not greater than " + limit + ") error , Please re-enter :");
continue; } break; } return line; } public static void loadSpecialEffects()
throws InterruptedException { System.out.println(" One moment please :"); for (int i1 = 1; i1
<= 100; i1++) { System.out.print(" Loading :" + i1 + "%"); Thread.sleep(new
Random().nextInt(25) + 1); if (i1 == 100) { Thread.sleep(50); }
System.out.print("\r"); } } // Convert all numeric strings to int type , And return its value public static int
printInt(String x){ Scanner sc = new Scanner(System.in);
if(isNumberic(x)==true){ int y = Integer.parseInt(x); return y; }else{
while(true){ System.out.print(" The value you entered is meaningless ! Please re-enter : "); String num = sc.next();
if(isNumberic(num)==true){ int y1 = Integer.parseInt(num); return y1; } } } }
// Determine whether the string is all numbers , Yes, back true, Otherwise return false public static boolean isNumberic(String str) {
// Use regular expressions to determine whether they are all numbers Pattern pattern = Pattern.compile("[0-9]*"); return
pattern.matcher(str).matches(); } }
2, Picture display tool class (PayView)
import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import
java.io.File; /* * Generate QR code * The following code only needs to change a picture *new PayView();// Create this object to display the payment picture */
public class PayView extends JFrame{ MyPanel mp=null; public PayView(){ mp=new
MyPanel(); this.add(mp); this.setSize(1273, 809);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setVisible(true);
} public static void main(String[] args){ new PayView(); } } class MyPanel
extends JPanel{ Image image=null; public void paint(Graphics g){ try { image=
ImageIO.read(new File("eighth\\src\\MathDemo\\name\\ Look, you'll be responsible .jpg"));
g.drawImage(image, 0, 0, 1273, 809, null); } catch (Exception e) { // TODO
Auto-generated catch block e.printStackTrace(); } } }

  two , Functions of login interface
/* Login interface */ import java.io.File; import java.io.FileReader; import
java.io.FileWriter; import java.io.IOException; import java.util.Properties;
import java.util.Random; import java.util.Scanner; public class loginView {
public static final Scanner sc=new Scanner(System.in); public static int
money=0; public static int count=1; // User login registration public void Login() throws
InterruptedException, IOException { // Circular judgment boolean flag=true; // Definition file File f1;
File f2; // aggregate Properties prop=new Properties(); // Cycle control while (flag){
System.out.println(" Please enter your account & password "); System.out.print(" account number :"); String
userName=sc.next(); // File path initialization f1=new
File("eighth\\src\\MathDemo\\name",userName); // Judge whether the file exists or not if (!f1.exists()){
System.out.println(" The account information you entered does not exist , Please select whether to register (y/n)."); char
c=TSUtility.readConfirmSelection(); if (c=='Y'){ System.out.print(" Account number is :");
String userName1=sc.next(); f2=new
File("eighth\\src\\MathDemo\\name",userName1); System.out.print(" Password is :"); String
password1=sc.next(); prop.setProperty("Password",password1);
prop.setProperty("Money", String.valueOf(money)); prop.setProperty("Count",
String.valueOf(count)); FileWriter fw=new FileWriter(f2); // Assemble to file
prop.store(fw,"------UserInfo------"); fw.close();
TSUtility.loadSpecialEffects(); System.out.println(" login was successful ."); }else {
System.out.println(" Unregistered , Do you want to exit the system (y/n)"); char
c1=TSUtility.readConfirmSelection(); if (c1=='Y'){ System.exit(0); }else {
System.out.println(" Please re-enter your account & password "); } } }else { System.out.print(" password :"); String
pw=sc.next(); FileReader fr=new FileReader(f1); prop.load(fr); fr.close();
// Judge whether it is correct if (prop.getProperty("Password").equals(pw)){
System.out.println(userName + " Welcome ! " +userName+ " Your current balance is :" +
prop.getProperty("Money") + " element , Free times are :" + prop.getProperty("Count")); flag =
false; // Guessing games , Start playing games loginView.guessNumber(prop,f1); }else {
System.out.println(" Password error , Please log in again ."); } } } } // Figure guessing game public static void
guessNumber(Properties prop, File f1) throws IOException { Scanner sc = new
Scanner(System.in); System.out.println(" Universe supreme game : Guess the number (0-100)");
System.out.println(" start !"); while (true) { int count1 =
Integer.parseInt(prop.getProperty("Count")); int money1 =
Integer.parseInt(prop.getProperty("Money")); if (count1 <= 0 && money1 < 50) {
System.out.println(" Sorry, your credit is running low , Do you want to recharge ?(y/n)"); char c =
TSUtility.readConfirmSelection(); if (c == 'Y') { addMoney(prop, f1); } else {
System.out.println(" Recharge exited , White whoring's breakfast has a mellow claw ."); break; } } else { Random r = new
Random(); // Generate random number int number = r.nextInt(101); System.out.println(" Test use :" +
number); while (true) { System.out.println(" Please enter the number you want to guess :"); int guessnumber =
sc.nextInt(); if (guessnumber > number) { System.out.println(" You guessed the number " +
guessnumber + " Big "); } else if (guessnumber < number) {
System.out.println(" You guessed the number " + guessnumber + " Small "); } else {
System.out.println(" Congratulations on your guess "); // Determine whether there are still games if (count1 != 0) { count1--; // Times minus one
// Change in set count value prop.setProperty("Count", String.valueOf(count1)); } else {
// Determine whether there is a balance if (money1 != 0) { // Set usage amount 50 Yuan play once money1 -= 50; // Change in set Money value
prop.setProperty("Money", String.valueOf(money1)); } } break; } } }
// The contents of the collection are written to a file FileWriter fw = new FileWriter(f1); prop.store(fw, null);
fw.close(); System.out.println(" Keep playing ? y/n"); char c =
TSUtility.readConfirmSelection(); if (c == 'Y') { // Get the value again , In order to ensure that the data obtained is the data after recharge int
count2 = Integer.parseInt(prop.getProperty("Count")); int money2 =
Integer.parseInt(prop.getProperty("Money")); // Judge whether there are conditions for playing if (count2 <= 0 &&
money2 < 50) { System.out.println(" Sorry, your credit is running low , Recharge or not y/n"); char c1 =
TSUtility.readConfirmSelection(); if (c1 == 'Y') { // Recharge module addMoney(prop, f1); }
else { System.out.println(" Recharge exited !"); break; } } } else {
System.out.println(" Quit the game !"); break; } } } // Voucher Center private static void
addMoney(Properties prop,File f1) throws IOException { while (true){
System.out.println("¥¥¥¥ Recharge system ¥¥¥¥"); System.out.println("¥¥ Charge 100 to send 5 second ¥¥");
System.out.println("¥¥ Charge 200 to send 12 second ¥¥"); System.out.println("¥¥ Charge 300 to send 18 second ¥¥");
System.out.println("¥ Charge 500 and above 31 second ! ¥"); System.out.println("¥¥¥¥ Recharge system ¥¥¥¥");
System.out.println(" Please enter your recharge amount :"); String s=sc.next(); int
money=TSUtility.printInt(s); while (true){ if (money != 100 && money != 200 &&
money != 300 && money < 500){ System.out.println(" Wrong amount entered ! Please re-enter :"); String s1 =
sc.next(); int money1 = TSUtility.printInt(s1); money = money1; } else {
prop.setProperty("Money", String.valueOf(money)); if (money==100){
prop.setProperty("Count", String.valueOf(5)); }else if (money == 200){
prop.setProperty("Count", String.valueOf(12)); }else if (money == 300){
prop.setProperty("Count", String.valueOf(18)); }else {
prop.setProperty("Count", String.valueOf(31)); } FileWriter fw=new
FileWriter(f1); prop.store(fw,null); fw.close(); System.out.println(" Recharge succeeded !");
break; } } break; } } // User modification public void revise() throws InterruptedException,
IOException { Properties prop=new Properties();
System.out.println(" Please enter the account you want to modify "); String userName=sc.next(); File file=new
File("eighth\\src\\MathDemo\\name",userName); if (!file.exists()){
System.out.println(" The account information you entered does not exist ."); }else { FileReader fr=new FileReader(file);
prop.load(fr); fr.close(); // Change Password System.out.print(" Please enter the new password you want to change (" +
"( Old password :"+prop.getProperty("Password")+")" + "):"); String pw = sc.next();
// Modifying data in a collection prop.setProperty("Password", pw); // Assemble to file FileWriter fw = new
FileWriter(file); prop.store(fw, null); fw.close();
System.out.println(" Password modified successfully !"); System.out.println(" Current account :" + userName);
System.out.println(" Current password :" + pw); } } }

three , Separately written guessing games
import java.io.FileWriter; import java.io.IOException; import
java.util.Properties; import java.util.Random; import java.util.Scanner; public
class HandGame { public static void handGame() throws IOException {
System.out.println(" The rules are as follows :");
System.out.println("1 Represents scissors ,2 Represents stone ,3 Representative cloth . scissors < stone < cloth , stone < cloth < scissors , cloth < scissors < stone ");
System.out.println("-------------------"); FileWriter fw=new
FileWriter("eighth\\src\\MathDemo\\name\\ System fist .txt"); fw.write("1= scissors \r\n");
fw.write("2= stone \r\n"); fw.write("3= cloth \r\n"); fw.close(); Properties prop=new
Properties(); prop.setProperty("1"," scissors "); prop.setProperty("2"," stone ");
prop.setProperty("3"," cloth "); while (true){ Scanner sc=new Scanner(System.in);
System.out.println(" stone 2, scissors 1, cloth 3!!! Give me a hand .laozi Want number ."); int hand=sc.nextInt();
Random r=new Random(); int i = r.nextInt(3)+1; if (hand==1 && i==1){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" You're even with the system ?laji..."); }else if (hand==1 && i==2){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" so what ? You lost ?ztmlaji..."); }else if (hand==1 && i==3){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" That's the win ? ah tui,dtmlaji..."); }else if (hand==2 && i==1){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" That's the win ? ah tui,dtmlaji..."); }else if (hand==2 && i==2){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" You're even with the system ?laji..."); }else if (hand==2 && i==3){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" so what ? You lost ?ztmlaji..."); }else if (hand==3 && i==1){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" so what ? You lost ?ztmlaji..."); }else if (hand==3 && i==2){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" That's the win ? ah tui,dtmlaji..."); }else if (hand==3 && i==3){
System.out.println(" What did you say :"+prop.getProperty(String.valueOf(hand)));
System.out.println(" What's wrong with the system :"+prop.getProperty(String.valueOf(i)));
System.out.println(" You're even with the system ?laji..."); }
System.out.println("-------------------"); System.out.println(" Want to keep playing ? Fool, still playing ?
y/n"); char c = TSUtility.readConfirmSelection(); if (c != 'Y') {
System.out.println(" Quit the game !( It's time to go ...)"); break; } } } }

four , That's all the code , That's the game .

Technology