閑來無事,寫著玩玩
import java.util.*;
public class NjavaT01{
???? public static int Player(String player){
???????? switch (player){
???????????? case "Jeason":
???????????????? return 132457;
???????????? case "Steven":
???????????????? return 111222;
???????????? default:
???????????????? return -1;
???????? }
???? }
???? public static void main(String[] args) {
???????? Scanner sc = new Scanner(System.in);
???????? System.out.println("Please enter your player's name:");
???????? String name = sc.next();
???????? String GREETING = "Hello!";
???????? System.out.println("Please enter your password:");
???????? int password = sc.nextInt();
???????? int realcode = Player(name);
???????? if(realcode != -1){
???????????? if(password == Player(name)){
???????????????? System.out.println(GREETING + name);
???????????? }
???????????? else{
???????????????? System.out.println("The password is incorrect.Sorry!");
???????????? }
???????? }
???????? else{
???????????? System.out.println("Hey, please regisit on before you log in.");
???????? }
???? }
}