编写一个小程序
需求:
- 定义一个类型User
属性:
用户名:username
密码:password
年龄:age
出生日期:birthday
真实姓名:realName
邮箱:email - 定义一个类型Server(服务器)
属性:
Map<String,User> map: 用于存储用户的注册信息
方法:
boolean register(User user)
boolean login(String username,String password)
void saveUser(User user)
(用户信息保存在文件user.txt中)
代码
User.java
package com.hyxy.homework;
import java.util.Date;
public class User {
private String username;
private String password;
private int age;
private Date birthday;
private String realName;
private String email;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
pu