日期:2014-05-20 浏览次数:20886 次
package chapter08;
import java.util.Scanner;
public class Demo1 {
static Scanner console = null;
static String name;
static String password;
static int id;
public static void main(String[] args) {
// TODO Auto-generated method stub
choseMenu();
}
private static void choseMenu() {
// TODO Auto-generated method stub
System.out.println("****欢迎进入奖客富翁系统****");
System.out.println("\t1.注册\n\t2.登陆\n\t3.抽奖");
System.out.println("***********************");
System.out.print("请选择菜单:");
int i = console.nextInt();
switch(i){
case 1: register(); break;
case 2: login(); break;
case 3: lottery(); break;
}
}
private static void lottery() {
// TODO Auto-generated method stub
System.out.println("[奖客富翁系统>抽奖]");
}
private static void register() {
// TODO Auto-generated method stub
System.out.println("[奖客富翁系统>注册]");
System.out.println("请填写个人注册信息:");
System.out.print("用户名:");
name = console.next();
System.out.println("密码:");
password = console.next();
System.out.println("注册成功!请记住您的账号和密码");
id=(int)(Math.random()*9999);
System.out.println("账号\t\t密码\t\tid");
System.out.println(name+"\t\t"+password+"\t\t"+id);
System.out.println("继续吗?(y/n)");
String s =console.next();
if(s.equals("y")){
choseMenu();
}
}
private static void login() {
// TODO Auto-generated method stub
System.out.println("[奖客富翁系统>登陆]");
}
}
?static?Scanner?console?=?null;
package xin;
import java.io.Console;
import java.util.Scanner;
public class test {
static Scanner console = null;
static String name;
static String password;
static int id;
public static void main(String[] args) {
// TODO Auto-generated method stub
choseMenu();
}
private static void choseMenu() {
// TODO Auto-generated method stub
System.out.println("****欢迎进入奖客富翁系统****");
System.out.println("\t1.注册\n\t2.登陆\n\t3.抽奖");
System.out.println("***********************");
System.out.print("请选择菜单:");
console = new Scanner(System.in);
int i = console.nextInt();
switch(i){
case 1: register(); break;
case 2: login(); break;
case 3: lottery(); break;
}
}
private static void lottery() {
// TODO Auto-generated method stub
System.out.println("[奖客富翁系统>抽奖]");
}
private static void register() {
// TODO Auto-generated method stub
System.out.println("[奖客富翁系统>注册]");
System.out.println("请填写个人注册信息:");
System.out.print("用户名:");
name = console.next();
System.out.println("密码:");
password = console.next();
System.out.println("注册成功!请记住您的账号和密码");
id=(int)(Math.random()*9999);
System.out.println("账号\t\t密码\t\tid");
System.out.println(name+"\t\t"+password+"\t\t"+id);
System.out.println("继续吗?(y/n)");
String s =console.next();
if(s.equals("y")){
choseMenu();