学习Java已经一个月了,运用所学的知识,简单做了一个学生信息管理系统,由于还没有开始学习数据库,所以用ArrayList集合来存储学生信息数据,用HashSet存储用户信息。
注:学生id必须是int数据。且是从1开始顺序添加,否则删除时会报错。此为一个小bug,有待改进。
代码如下:
Student.java
package com.briup.login;
public class Student {
private int id;
private String name;
private int age;
private double source;
public Student() {
super();
}
public Student(int id, String name, int age, double source) {
super();
this.id = id;
this.name = name;
this.age = age;
this.source = source;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getSource() {
return source;
}
public void setSource(double source) {
this.source = source;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", age=" + age + ", source=" + source + "]";
}
}
Customer.java
package com.briup.login;
public class Customer {
private String username;
private String password;
public Customer() {
super();
}
public Customer(String username, String password) {
super();
this.username = username;
this.password = password;
}
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;
}
@Override
public String toString() {
return "Customer [username=" + username + ", password=" + password + "]";
}
}
Login.java
<