实操3:提取百战婚恋交友的注册功能

Source
  • @author 祁蒙恩
  • 实操3:提取百战婚恋交友的注册功能
  • 实现思路:

import java.util.Scanner;

/**
 * @author 祁蒙恩
 * 实操3:提取百战婚恋交友的注册功能
 * 实现思路:
 * 	
 */
public class UserBiz2 {
	private static User[] user=new User[100];
	private static int count;
	private static int regCount;
	private Scanner input =new Scanner(System.in);
	private boolean isLogin=false;
	static{
		user[0]=new User("祁蒙恩","男","1998年9月12日","北京","未婚",180,18000,"18595915053","fzenz","旅游","本科");
		user[1]=new User("李姿锐","女","1998年5月12日","河南","未婚",162,8000,"18595915053","fzenz","旅游","本科");
		user[2]=new User("祁蒙恩1","男","1998年9月12日","河南","未婚",180,18000,"18595915053","fzenz","旅游","本科");
		user[3]=new User("李姿锐2","女","1998年5月12日","河南","未婚",162,8000,"18595915053","fzenz","旅游","本科");
		regCount=4;
	}
	public void mainMenu(){
		while(true){
			System.out.println("百战婚恋交友\t严肃的婚恋网站\t\t\t公有"+regCount+"个人用户,当前北京地区"+count+"在线征婚!");
			System.out.println("---------------------------------------------------------");
			System.out.println("\t1.注册\t2.登录\t3.查询心仪对象\t4.退出");
			System.out.println("---------------------------------------------------------");
			int choice=input.nextInt();
			switch(choice){
			case 1:
				register();
				continue;
			case 2:
				login();
				continue;
			case 3:
				if(isLogin){
					select();
				}else{
					System.out.println("请先登录,再查询!");
				}
				continue;
			case 4:
				System.out.println("程序退出,谢谢使用!");
				break;
			default:
				System.out.println("对不起,选择有误!");
				continue;
			}
			break;
		}
	}
	private void addUser(User u){
		for(int i=0;i<user.length;i++){
			if(user[i]==null){
				user[i]=u;
				regCount++;//注册人数
				break;
			}
		}
	}
	private void select(){
		
	}
	private void login(){
		
	}
	private void register(){
		System.out.println("======================青春不常在,抓紧谈恋爱======================");
		System.out.println("会员注册");
		System.out.print("我是:男\t女");
		String gender=input.next();
		System.out.print("生日:(yyyy年MM月dd日)");
		String birthday=input.next();
		System.out.print("常住地址:");
		String address=input.next();
		System.out.print("婚姻状况:未婚\t离婚\t丧偶");
		String marryState=input.next();
		System.out.print("身高:");
		double height=input.nextDouble();
		System.out.print("学历:");
		String degreeOfLearning=input.next();
		System.out.print("月薪:");
		double salary=input.nextDouble();
		System.out.print("手机号:");
		String phone=input.next();
		int random=(int)(Math.random()*9000+1000);
		System.out.print("验证码:"+random+"\t");
		
		int checkNumber=input.nextInt();
		while(checkNumber!=random){
			System.out.print("验证码不正确");
			checkNumber=input.nextInt();
		}
		System.out.print("密码:");
		String password=input.next();
		System.out.print("昵称:");
		String nickName=input.next();
		System.out.print("自我介绍:(诚信、稳重、开朗)自己写");
		String introduce=input.next();
/**		
		private String nickName;		//昵称
		private String gender;			//性别
		private String birthday;		//出生日期
		private String address;			//常住地址
		private String marryState;		//婚姻状况
		private double height;			//身高
		private double salary;			//月薪
		private String phone;			//手机号
		private String password;		//密码
		private String introduce;		//自我介绍
		private String degreeOfLearning;	//学历
	**/	
		User u=new User(nickName,gender,birthday,address,marryState,height,salary,phone,password,introduce,degreeOfLearning);
		addUser(u);
		System.out.println("\n"+nickName+",恭喜你成为百战婚恋的会员,开始登陆查询心仪的对象吧!\n");
	
	}
	
	
}


























在这里插入图片描述