[代码展示]登录
还请各位帮忙看看,修改一下
注:这不能生成一个登录界面,而是一个思路
import java.util.*;
public class NjavaT01 {
public static void greeting(String name) {
System.out.println("Hello, "+name+" ! Welcome to CoLand.");
}
static Map<String,String> userStorage = new HashMap<>();
public static void main(String []args) {
MAINLOOP:while(true){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter your order(number): ");
System.out.println("1. login.");
System.out.println("2. register.");
int order = sc.nextInt();
if(order == 1) {
System.out.println("Please enter your nameL: ");
String usernameL = sc.next();
if(userStorage.containsKey(usernameL)) {
for(int i = 3;i >= 0;i--) {
System.out.println("Please enter you passwordL: ");
String passwordL = sc.next();
if(passwordL.equals(userStorage.get(usernameL))) {
greeting(usernameL);
break MAINLOOP;
} else {
System.out.println("Your password is wrong.");
System.out.println("Please try again !");
}
}
} else {
System.out.println("Your name is not exist.");
System.out.println("Please try again or to regist");
}
} else if(order == 2) {
System.out.println("Please enter your nameR: ");
String usernameR = sc.next();
System.out.println("Please enter your passwordL:");
String passwordR = sc.next();
LOOP:for(int i = 3;i >= 0;i--) {
System.out.println("Please enter your password again:");
String passwordRR = sc.next();
if(passwordR.equals(passwordRR)) {
userStorage.put(usernameR,passwordR);
System.out.println("You have successfully regist");
break LOOP;
}else {
System.out.println("Your passwords can not match.");
}
}
} else {
System.out.println("Your order is wrong !");
}
}
}
}

