一、项目内容
项目功能结构图:
项目功能如下:
(1)登录注册功能
:用户通过注册进入平台,注册信息包括用户编号(用户编号决定角色类型,学号注册为兼职人员,教师编号注册为管理员),注册后到登录界面输入账号和密码登录平台,注册信息包括:用户编号(学号/教师编号)、密码、姓名、出生日期、性别、电话、所在院系、注册日期等。后期如果忘记了密码,用户通过自己的账号和注册时的姓名找回密码。注意,为了安全起见,只有已经录入系统的用户可以注册账户,本平台提前录入了部分管理员和学生的信息到系统中供大家注册。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
(2)个人信息管理
:包括个人信息修改、密码修改、查询信用等级和查询余额功能
。普通用户登录成功之后,可以修改个人注册时录入的信息,学号和注册时间不可更改,密码单独修改;也可以查询个人的信用等级,若信用等级不是最高,则查询个人信用等级时附加显示“按时完成X次后信用等级恢复至X级”(默认未逾期完成兼职工作3次恢复1级信用等级,等级梯度为1-5级,5级最高)。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
(3)兼职申请功能
:包括兼职信息查询、申请工作和结束工作
。用户登录成功之后,可以查询所有的兼职信息,包括自己能申请的职位和不能申请的职位,也可以只查看自己能申请的职位(是否可申请与信用等级、岗位所需人员、兼职时间相关)。用户还可查看自己已完成的兼职信息和自己正在完成的兼职信息。满足条件的兼职,用户可以申请,开始工作时间为系统当前时间,相对的该兼职岗位对应的所需人员需要减少;完成工作后(逾期完成信用自动降低1级,0级为最低,0级后不可再申请兼职工作),需要计算所得薪酬(所得薪酬和是否逾期、逾期天数相关),若未逾期且信用等级未满,则需要计算恢复信用等级所需的次数,完成时间手动输入,不可小于兼职开始时间。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
(4)基本信息维护功能
:包括兼职等级设置、用户信用调整和逾期费用扣除比例调整
。管理员端登录成功之后,可以调整兼职的等级(兼职等级梯度为一-五级,五级最高,一级最低),普通用户的信用等级>=兼职等级可申请职位,还可以增删兼职的类型,比如开发外包/销售/设计师等。管理员可以根据用户的表现动态地调整用户的信用等级,可越级增减,0级信用的普通用户管理员不可调整其信用等级。管理员还可以调整兼职的逾期费用,每天逾期扣除的费用相同,比如:原定一份兼职总薪资1000元,工作要求10天完成,逾期1天扣除100元,调整后一天扣除200元(扣除兼职费用为0后继续扣除用户余额,直到用户余额为<=0,自动结束工作,结算费用)。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
(5)兼职信息投放
:包括兼职人员设置、兼职的金额设置、兼职的时间录入以及兼职的其他信息录入
。系统管理员登录成功之后可以把所有公司发布的兼职信息录入到平台,录入信息包括:营业执照编号、公司名字、岗位名称、兼职类型、兼职等级、工作内容、需求人数、工作时间等。系统管理员可以根据市场和公司要求,动态调整这些兼职工作的部分内容,比如需求人数、薪水等,工作时间不允许更改。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
(6)系统管理功能
:包括对普通用户、管理员和兼职信息的增删查改等
。系统提前录入了一些管理员或者学生的信息在系统中,但是未全部录入,所以后续需要注册的用户需要已经录入的管理员登录平台进行信息录入,系统录入仅需要学号/教师编号和姓名即可,此信息供用户注册使用。管理员可以删除普通用户和别的管理员,以及没有用的兼职信息。(相关存储数据可通过I/O流直接存在文件,可也直接在文件里读的数据)
二、项目构想以及实施
2.1框架
2.2 实施
2.2.1 domin
2.2.1.1 JobInformation
package xuexi.java.guanka16Restart1.domin;
import java.text.SimpleDateFormat;
import java.util.Date;
//兼职信息实体(与文件里面兼职信息里面的信息一致)营业职业编号为连通的键
public class JobInformation {
private String jobId;//营业执照编号
private String company_name;//工资名字
private String job_name;//岗位名称
private String jobtype_name;//兼职类型
private int job_level;//兼职等级
private String workContent;//工作内容
private int needPeople;//需求人数
private String job_time;//工作时间
private double salary;//薪水
private String deduct_salary;//逾期费用扣除比例
//有参无参get/set方法
public JobInformation() {
}
public JobInformation(String jobId, String company_name, String job_name, String jobtype_name, int job_level, String workContent, int needPeople, String job_time, double salary, String deduct_salary) {
this.jobId = jobId;
this.company_name = company_name;
this.job_name = job_name;
this.jobtype_name = jobtype_name;
this.job_level = job_level;
this.workContent = workContent;
this.needPeople = needPeople;
this.job_time = job_time;
this.salary = salary;
this.deduct_salary = deduct_salary;
}
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getCompany_name() {
return company_name;
}
public void setCompany_name(String company_name) {
this.company_name = company_name;
}
public String getJob_name() {
return job_name;
}
public void setJob_name(String job_name) {
this.job_name = job_name;
}
public String getJobtype_name() {
return jobtype_name;
}
public void setJobtype_name(String jobtype_name) {
this.jobtype_name = jobtype_name;
}
public int getJob_level() {
return job_level;
}
public void setJob_level(int job_level) {
this.job_level = job_level;
}
public String getWorkContent() {
return workContent;
}
public void setWorkContent(String workContent) {
this.workContent = workContent;
}
public int getNeedPeople() {
return needPeople;
}
public void setNeedPeople(int needPeople) {
this.needPeople = needPeople;
}
public String getJob_time() {
return job_time;
}
public void setJob_time(String job_time) {
this.job_time = job_time;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public String getDeduct_salary() {
return deduct_salary;
}
public void setDeduct_salary(String deduct_salary) {
this.deduct_salary = deduct_salary;
}
@Override
//重写toString方法
public String toString() {
return "营业执照编号:" + jobId + ", 公司名字:" + company_name +
", 岗位名称:" + job_name + ",兼职名称 " + jobtype_name + ",兼职等级:" + job_level +
", 工作内容:" + workContent +
", 需求人员:" + needPeople +
", 工作时间:" + job_time +
", 薪资:" + salary +
", 逾期费用扣除比例:" + deduct_salary;
}
//申请之后录入的信息
public String inToString(){
Date s8=new Date();//s8为当前时间
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化为指定日期字符串
String ss=sdf.format(s8);
return toString()+",开始时间:"+ss;
}
}
2.2.1.2 User
package xuexi.java.guanka16Restart1.domin;
//用户实体 用户编号为连通的键
public class User {
private String uid;//用户编号
private String password;//密码
private String username;//姓名
private int age;//年龄
private String sex;//性别
private String phone;//电话
private String department;//所在院系
private String registrationDate;//注册日期
//有参无参get/set方法
public User() {
}
public User(String uid, String password, String username, int age, String sex, String phone, String department, String registrationDate) {
this.uid = uid;
this.password = password;
this.username = username;
this.age = age;
this.sex = sex;
this.phone = phone;
this.department = department;
this.registrationDate = registrationDate;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getRegistrationDate() {
return registrationDate;
}
public void setRegistrationDate(String registrationDate) {
this.registrationDate = registrationDate;
}
//重写toString方法
@Override
public String toString() {
return "编号:"+uid+",密码:"+password+",姓名:"+username+",年龄:"+age+",性别:"+sex+",电话:"+phone+",所在院系:"+department+",注册日期:"+registrationDate;
}
}
2.2.1.3 UserAccount
package xuexi.java.guanka16Restart1.domin;
//用户账户(包括账户编号,信用等级,余额)
//此为初始账户,为文件内的,只要文件中有此账户信息的人员才能注册
public class UserAccount {
private String accountId;//账户编号
private int credit_rating;//信用等级
private double balance;//余额
//有参无参get/set方法
public UserAccount(String accountId, int credit_rating, double balance) {
this.accountId = accountId;
this.credit_rating = credit_rating;
this.balance = balance;
}
public UserAccount() {
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public int getCredit_rating() {
return credit_rating;
}
public void setCredit_rating(int credit_rating) {
this.credit_rating = credit_rating;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
}
2.2.2 service
2.2.2.1 ExceptionTest
2.2.2.1.1 MoreThanException
package xuexi.java.guanka16Restart1.service.ExceptionTest;
//错误次数太多时异常
public class MoreThanException extends Exception {
public MoreThanException() {
}
public MoreThanException(String message) {
super(message);
}
}
2.2.2.2 function
2.2.2.2.1 Basic_Information_Management
package xuexi.java.guanka16Restart1.service.function;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
//基本信息维护管理(管理员)
public class Basic_Information_Management {
//兼职等级设置
public void setJobLevel( ArrayList<JobInformation> jobInformations) throws IOException {
if(jobInformations.size()==0){
System.out.println("暂无兼职");
return;
}
Tool.showJobInformation(jobInformations);
System.out.println("请选择兼职(临时编号):");
int x=jobInformations.size();
int a=Tool.inTypeInt(x)-1;
JobInformation s=jobInformations.get(a);
System.out.println("兼职等级设置为(原等级:"+s.getJob_level()+"):");
int t=Tool.inLeval();
s.setJob_level(t);
jobInformations.set(a,s);
Tool.inJobManagement(jobInformations);
System.out.println("设置成功");
}
//兼职类型设置
public void setJobType(Properties propJob, ArrayList<JobInformation> jobInformations) throws IOException {
if(jobInformations.size()==0){
System.out.println("暂无兼职");
return;
}
Tool.showJobInformation(jobInformations);
System.out.println("请选择兼职(临时编号):");
int x=jobInformations.size();
int a=Tool.inTypeInt(x)-1;
JobInformation s=jobInformations.get(a);
System.out.println("兼职类型设置为(原类型:"+s.getJobtype_name()+"):");
String t=Tool.inType(propJob);
s.setJobtype_name(t);
jobInformations.set(a,s);
Tool.inJobManagement(jobInformations);
System.out.println("设置成功");
}
//用户信用调整
public void setPeopleBelieve(ArrayList<UserAccount> userAll) throws IOException {
System.out.println("请输入需要调整的用户ID:");
String s=Tool.inputString();
if(Long.valueOf(s)>=0&&Long.valueOf(s)<=9999){
System.out.println("注意:此用户为管理员,信用仅供参考,但不受限制");
}
int sum=0;
for(UserAccount userAccount:userAll){
if(userAccount.getAccountId().equals(s)){
System.out.println("将此用户信用调整为(原信用:"+userAccount.getCredit_rating()/10+"):");
int a=Tool.changeBelieve()*10+userAccount.getCredit_rating()%10;
userAccount.setCredit_rating(a);
userAll.set(sum,userAccount);
Tool.inPeopleAll(userAll);
System.out.println("设置成功");
return;
}
sum++;
}
System.out.println("用户不存在");
return;
}
//逾期费用扣除比例
public void setOverdueMoney( ArrayList<JobInformation> jobInformations) throws IOException {
Tool.showJobInformation(jobInformations);
System.out.println("请选择兼职(临时编号):");
int x=jobInformations.size();
int a=Tool.inTypeInt(x)-1;
JobInformation s=jobInformations.get(a);
System.out.println("兼职逾期费用比例设置为(原比例:"+s.getDeduct_salary()+"):");
String t=Tool.inDeduct();
s.setDeduct_salary(t);
jobInformations.set(a,s);
Tool.inJobManagement(jobInformations);
System.out.println("设置成功");
}
}
2.2.2.2.2 Job_Apply_Management
package xuexi.java.guanka16Restart1.service.function;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
//兼职申请管理(用户)
public class Job_Apply_Management {
//查询所有的职位信息
public void seeAllJob(ArrayList<JobInformation> jobInformations){
for(JobInformation jobInformation:jobInformations){
System.out.println(jobInformation.toString());
}
}
//只查询自己能够申请的职位信息
public void seeSomeJob(String s,ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll){
int mark = 0;
//查询得到自己的信用
for(UserAccount u:userAll){
if(u.getAccountId().equals(s)){
mark=u.getCredit_rating();
}
}
//通过信用和人数判断是否能够申请
for(JobInformation j:jobInformations){
if(j.getNeedPeople()!=0){
if(j.getJob_level()<=mark){
System.out.println(j.toString());
}
}
}
}
//查询已经完成过的兼职信息
public void seeAllFinishJob(String s,ArrayList<String> jobButFinish){
if(jobButFinish.size()==0){
System.out.println("暂无");
return;
}
for(String ss:jobButFinish){
String[] c=ss.split(",");
String cc=c[0].split(":")[1];
if(cc.equals(s)){
System.out.println(ss);
}
}
}
//查询正在完成的兼职信息
public void seeMySomeJob(String s,Properties jobWorking){
System.out.println("用户:"+s+" "+jobWorking.getProperty(s));
}
//兼职申请
public void openJob(String s, ArrayList<JobInformation> jobInformations, ArrayList<UserAccount> userAll, ArrayList<String> jobAll,ArrayList<String> jobButFinish,Properties jobWorking) throws IOException {
if(jobInformations.size()==0){
System.out.println("还没有兼职哦");
return;
}
if(Tool.alreadyJob(s,jobAll,jobButFinish)){
System.out.println("请先完成已有兼职");
return;
}
int sum=1;
for(JobInformation jobInformation:jobInformations){
System.out.println("编号:"+sum+jobInformation.toString());
sum++;
}
int mark = 0;
//查询得到自己的信用
for(UserAccount u:userAll){
if(u.getAccountId().equals(s)){
mark=u.getCredit_rating();
}
}
System.out.println("请选择你想申请的兼职(输入编号):");
int a= Tool.inTypeInt(jobInformations.size())-1;
JobInformation j=jobInformations.get(a);
jobInformations.remove(j);
if(j.getNeedPeople()!=0){
if(j.getJob_level()<=mark){
// jobAll.setProperty(s,j.inToString());
// FileWriter fr1 = new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobAll");
// jobAll.store(fr1,null);
// fr1.close();
jobAll.add("账户:"+s+","+j.inToString());
Tool.inAllJob(jobAll);
//存入正在进行的兼职中
jobWorking.setProperty(s,j.inToString());
FileWriter fr2 = new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobWorking");
jobWorking.store(fr2,null);
fr2.close();
int b=j.getNeedPeople()-1;
j.setNeedPeople(b);
jobInformations.add(j);
Tool.inJobManagement(jobInformations);
System.out.println("申请成功");
return;
}
}
System.out.println("申请失败,无法申请此兼职");
}
//结束工作
public void closeJob(String s, ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime,Properties jobWorking,ArrayList<UserAccount> userAll) throws ParseException, IOException {
if(jobWorking.getProperty(s)==null){
System.out.println("您还没有工作,无法结束");
return;
}
Date s8=new Date();//s8为当前时间
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化为指定日期字符串
String u=jobWorking.getProperty(s);
String[] c=u.split(",");
int a=c.length;
String[] cc=c[a-1].split(":");
// System.out.println(sdf.parse(ss).getTime());
double time= (sdf.parse(cc[1]).getTime()-s8.getTime())*1.0/1000/60/60/24;//得到完成所用时间(天)
//规定时间天数
String[] sj=c[a-1-3].split(":");
int b=sj[1].length();
double time1=Double.valueOf(sj[1].substring(0,b-1));
//得到逾期比例
String y=c[a-1-1].split(":")[1];
int j=y.length();
double yq=Double.valueOf(y.substring(0,j-1));
//得到薪资
double x=Double.valueOf(c[a-1-2].split(":")[1]);
//得到用户信用(包含次数) 用户余额
int xysum=0;
double money=0;
UserAccount us=null;//用户信息
for(UserAccount userAccount:userAll){
if(userAccount.getAccountId().equals(s)){
us=userAccount;
xysum=userAccount.getCredit_rating();
money=userAccount.getBalance();
userAll.remove(us);//删除原本用户信息,方便后面修改后存入
break;
}
}
//如果所用时间大于规定时间,则逾期,存入进逾期文件类,并计算逾期薪资
if(time>time1){
jobButOverTime.add("账户:"+s+","+u);
Tool.inJobButOverTime(jobButOverTime);
money+=x*(100-yq)/100;
xysum-=10;
us.setCredit_rating(xysum);
us.setBalance(money);
userAll.add(us);
Tool.inPeopleAll(userAll);
jobButFinish.add("账户:"+s+","+u);
Tool.inJobButFinish(jobButFinish);
jobWorking.remove(s);
//删除文件中的正在进行的兼职
FileWriter fr2 = new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobWorking");
jobWorking.store(fr2,null);
fr2.close();
if(xysum/10==0){
System.out.println("您的信用为零,兼职生涯到此为止吧,再见");
System.exit(0);
}
}else{
money+=x;
if(xysum==50){
}else {
if(xysum%10==2){
xysum+=8;
}else {
xysum+=1;
}
}
us.setCredit_rating(xysum);
us.setBalance(money);
userAll.add(us);
Tool.inPeopleAll(userAll);
jobButFinish.add("账户:"+s+","+u);
Tool.inJobButFinish(jobButFinish);
jobWorking.remove(s);
FileWriter fr2 = new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobWorking");
jobWorking.store(fr2,null);
fr2.close();
}
}
}
2.2.2.2.3 LoginAndRegistration
package xuexi.java.guanka16Restart1.service.function;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.ExceptionTest.MoreThanException;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import xuexi.java.guanka16Restart1.view.administrator.AdministratorTotalMenu;
import xuexi.java.guanka16Restart1.view.people.PeopleTotalMenu;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
//登录与注册
public class LoginAndRegistration {
AdministratorTotalMenu administratorTotalMenu=new AdministratorTotalMenu();
PeopleTotalMenu peopleTotalMenu=new PeopleTotalMenu();
//进入系统
public void login(Properties propPeople, Properties propJob, ArrayList<User> users,ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll,ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime,Properties jobWorking) throws MoreThanException, IOException, ParseException {
while (true){
System.out.println("================欢迎来到校园兼职系统==================");
System.out.println("1.登录");
System.out.println("2.注册");
System.out.println("3.忘记密码");
System.out.println("4.退出系统");
System.out.println("请选择:");
String s=Tool.inputString();
switch (s){
case "1":log_In(propPeople,propJob,users,jobInformations,userAll,jobAll,jobButFinish,jobButOverTime,jobWorking);break;
case "2":try {
registration(propPeople,users,userAll);break;
}catch (MoreThanException e){
System.out.println("错误次数太多");
break;
}
case "3":findYourPassword(users);break;
case "4":System.exit(0);break;
default:
System.out.println("输入错误,请重新输入");
break;
}
}
}
//注册
public void registration(Properties propPeople,ArrayList<User> users,ArrayList<UserAccount> userAll) throws MoreThanException, IOException {
System.out.println("请输入账号(账号为编号):");
String s1=Tool.isAccount(propPeople,users);
System.out.println("请输入密码:");
String s2=Tool.inputString();
System.out.println("请输入姓名:");
String s3=Tool.isName(s1,propPeople);
System.out.println("请输入年龄:");
int s4=Tool.inputAge();
System.out.println("请输入性别:");
String s5=Tool.inputSex();
System.out.println("请输入电话:");
String s6=Tool.inputTel();
System.out.println("请输入所在院系:");
String s7=Tool.inputString();
// System.out.println("请输入注册日期:");
Date s8=new Date();//s8为当前时间
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化为指定日期字符串
// System.out.println(s8);
// System.out.println(sdf.format(s8));
String ss=sdf.format(s8);
// System.out.println(ss);
users.add(new User(s1,s2,s3,s4,s5,s6,s7,ss));
BufferedWriter bufferedReader=new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccountManagement",true));
String s=s1+","+s2+","+s3+","+s4+","+s5+","+s6+","+s7+","+ss;
bufferedReader.write(s);
bufferedReader.newLine();
bufferedReader.flush();
bufferedReader.close();
System.out.println("注册成功");
UserAccount userAccount=new UserAccount(s1,40,0);//信用设置为40,4表示信用,0表示完成次数
String n=userAccount.getAccountId()+","+userAccount.getCredit_rating()+","+userAccount.getBalance();
userAll.add(userAccount);
BufferedWriter bufferedReader1=new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAll",true));
bufferedReader1.write(n);
bufferedReader1.newLine();
bufferedReader1.flush();
bufferedReader1.close();
}
//登录
public void log_In(Properties propPeople, Properties propJob, ArrayList<User> users,ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll,ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime,Properties jobWorking) throws IOException, ParseException {
int a=0;
while (true){
if(a==3){
System.out.println("错误次数达到三次");
break;
}
a++;
System.out.println("请输入账号");
String s= Tool.inputString();
System.out.println("请输入密码");
String s1= Tool.inputString();
//判断账号密码是否错
boolean flag=passwordYesNo(s,s1,users);
if(flag){
System.out.println("账号或密码错误,请重新输入");
continue;
}
long l=Long.valueOf(s);
//判断账户是否是管理员
if(l>=0&&l<=9999){
administratorTotalMenu.interfaceDesign(s,propPeople,propJob,users,jobInformations,userAll,jobAll,jobButFinish,jobButOverTime);
break;
}else{
peopleTotalMenu.interfaceDesign(s,propPeople,propJob,users,jobInformations,userAll,jobAll,jobButFinish,jobButOverTime,jobWorking);
break;
}
}
}
//找回密码
public void findYourPassword(ArrayList<User> users){
System.out.println("请输入账号");
String s=Tool.inputString();
System.out.println("请输入预留的姓名");
String s1=Tool.inputString();
boolean flag=false;
for(User user:users){
if(user.getUid().equals(s)&&user.getUsername().equals(s1)){
System.out.println("您的密码为:"+user.getPassword());
flag=true;
}
}
if(!flag){
System.out.println("您的账号与预留姓名不匹配");
}
}
//判断输入的密码是否错误
public boolean passwordYesNo(String s,String s1,ArrayList<User> users){
for(User user:users){
String s2=String.valueOf(user.getUid());
String s3=String.valueOf(user.getPassword());
if(s.equals(s2)&&s1.equals(s3)){
return false;
}
}
return true;
}
}
2.2.2.2.4 Personal_Information_Management
package xuexi.java.guanka16Restart1.service.function;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import java.io.IOException;
import java.util.ArrayList;
//个人信息管理(用户)
public class Personal_Information_Management {
//个人信息修改
public void informationChange(String s,ArrayList<User> users) throws IOException {
User user = null;
for(User n:users){
if(s.equals(n.getUid())){
user=n;
users.remove(user);
break;
}
}
System.out.println("姓名:"+user.getUsername());
System.out.println("用户编号:"+user.getUsername());
// System.out.println("密码:"+user.getPassword());
System.out.println("注册日期:"+user.getRegistrationDate());
System.out.println("请输入修改后的年龄("+user.getAge()+"):");
int s1= Tool.changeAge();
System.out.println("请输入修改后的性别("+user.getSex()+"):");
String s2=Tool.changeSex();
System.out.println("请输入修改后的电话("+user.getPhone()+"):");
String s3=Tool.ChangeTel();
System.out.println("请输入修改后的院系("+user.getDepartment()+"):");
String s4=Tool.changeDepartment();
if(s1==-1){
}else {
user.setAge(s1);
}
if(s2.equals("")){
}else {
user.setSex(s2);
}
if(s3.equals("")){
}else {
user.setPhone(s3);
}
if(s4.equals("")){
}else {
user.setDepartment(s4);
}
users.add(user);
Tool.intPeopleAccountManagement(users);
}
//用户修改密码
public void peopleChangePassword(String s,ArrayList<User> users) throws IOException {
User user = null;
for(User n:users){
if(s.equals(n.getUid())){
user=n;
break;
}
}
System.out.println("请输入原密码");
String y=Tool.inputString();
if(y.equals(user.getPassword())){
users.remove(user);
System.out.println("请输入新密码");
String x=Tool.inputString();
user.setPassword(x);
users.add(user);
System.out.println("修改成功,您的密码修改为:"+user.getPassword());
Tool.intPeopleAccountManagement(users);
}else{
System.out.println("密码错误,无法修改");
}
}
// //管理员修改密码
// public void administratorChangePassWord(){
//
// }
//查询用户自身的信用等级
public void seePeopleLevel(String s,ArrayList<UserAccount> userAll){
UserAccount y = null;
for(UserAccount userAccount:userAll){
if(userAccount.getAccountId().equals(s)){
y=userAccount;
break;
}
}
System.out.println("您的信用等级为:"+y.getCredit_rating()/10);
if(y.getCredit_rating()/10==0){
System.out.println("您的信用等级为0,无法恢复等级亦不可接取兼职");
return;
}
if(y.getCredit_rating()<50){
System.out.println("按时完成"+(3*(5-y.getCredit_rating()/10)-y.getCredit_rating()%10)+"次后信用等级恢复至5级");
}
}
//查询余额
public void seeMoney(String s,ArrayList<UserAccount> userAll){
UserAccount y = null;
for(UserAccount userAccount:userAll){
if(userAccount.getAccountId().equals(s)){
y=userAccount;
break;
}
}
System.out.println("您的余额为:"+y.getBalance());
}
}
2.2.2.2.5 System_Management
package xuexi.java.guanka16Restart1.service.function;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
//系统管理
public class System_Management {
//删除管理员账号
public void deleteAdministrator(String s, ArrayList<User> users) throws IOException {
System.out.println("请输入管理员ID");
String x= Tool.inputString();
for(User u:users){
if(u.getUid().equals(x)){
if(Long.valueOf(u.getUid())>=0&&Long.valueOf(u.getUid())<=9999){
if(s.equals(x)){
System.out.println("不能删除自己");
return;
}else{
System.out.println("是否要删除此管理员账号(Y/N):");
if(Tool.YOrN()){
users.remove(u);
Tool.intPeopleAccountManagement(users);
System.out.println("删除成功");
return;
}else {
return;
}
}
}
}
}
System.out.println("不存在此管理员");
}
//删除用户账号
public void deletePeople(ArrayList<User> users) throws IOException {
System.out.println("请输入普通用户ID");
String x= Tool.inputString();
for(User u:users){
if(u.getUid().equals(x)){
if(Long.valueOf(u.getUid())>=0&&Long.valueOf(u.getUid())<=9999){
}else {
System.out.println("是否要删除此普通用户(Y/N):");
if(Tool.YOrN()){
users.remove(u);
Tool.intPeopleAccountManagement(users);
System.out.println("删除成功");
return;
}else {
return;
}
}
}
}
System.out.println("不存在此普通用户");
}
//兼职信息删除
public void deleteJob( ArrayList<JobInformation> jobInformations) throws IOException {
if(jobInformations.size()==0){
System.out.println("还没有兼职信息哦");
return;
}
int sum=1;
for(JobInformation j:jobInformations){
System.out.println("编号:"+sum+j.toString());
sum++;
}
System.out.println("请选择你想删除的兼职(输入编号):");
int a= Tool.inTypeInt(jobInformations.size())-1;
JobInformation ji=jobInformations.get(a);
jobInformations.remove(ji);
Tool.inJobManagement(jobInformations);
System.out.println("删除成功");
}
//添加用户账号
public void addPeople(Properties propPeople) throws IOException {
System.out.println("请输入用户ID:");
String s=Tool.addUser();
System.out.println("请输入用户姓名:");
String s1=Tool.inputString();
propPeople.setProperty(s,s1);
FileWriter fw=new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccount");
propPeople.store(fw,null);
fw.close();
}
//添加管理员账号
public void addAdministrator(Properties propPeople) throws IOException {
System.out.println("请输入管理员ID:");
String s=Tool.addAdministrator();
System.out.println("请输入管理员姓名:");
String s1=Tool.inputString();
propPeople.setProperty(s,s1);
FileWriter fw=new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccount");
propPeople.store(fw,null);
fw.close();
}
//修改密码
public void changePassword(String s,ArrayList<User> users) throws IOException {
User user = null;
for(User n:users){
if(s.equals(n.getUid())){
user=n;
break;
}
}
System.out.println("请输入原密码");
String y=Tool.inputString();
if(y.equals(user.getPassword())){
users.remove(user);
System.out.println("请输入新密码");
String x=Tool.inputString();
user.setPassword(x);
users.add(user);
System.out.println("修改成功,您的密码修改为:"+user.getPassword());
Tool.intPeopleAccountManagement(users);
}else{
System.out.println("密码错误,无法修改");
}
}
//查询所有用户信息
public void seeAllPeople(ArrayList<User> users){
for(User u:users){
if(Long.valueOf(u.getUid())>=0&&Long.valueOf(u.getUid())<=9999){
}else{
System.out.println(u.toString());
}
}
}
//查询管理员信息
public void seeAllAdministrator(ArrayList<User> users){
for(User u:users){
if(Long.valueOf(u.getUid())>=0&&Long.valueOf(u.getUid())<=9999){
System.out.println(u.toString());
}else{
}
}
}
//查询已经投放的职位信息
public void seeAllPutJob(ArrayList<JobInformation> jobInformations){
if(jobInformations.size()==0){
System.out.println("暂无");
return;
}
for(JobInformation jobInformation:jobInformations){
System.out.println(jobInformation.toString());
}
}
//查询已完成职位
public void seeAllFinishJob(ArrayList<String> jobButFinish){
if(jobButFinish.size()==0){
System.out.println("暂无");
return;
}
for(String s:jobButFinish){
System.out.println(s);
}
}
//查询逾期兼职信息
public void seeAllOverdueJob(ArrayList<String> jobButOverTime){
if(jobButOverTime.size()==0){
System.out.println("暂无");
return;
}
for(String s:jobButOverTime){
System.out.println(s);
}
}
}
2.2.2.3 tool
2.2.2.3.1 Tool
package xuexi.java.guanka16Restart1.service.tool;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.ExceptionTest.MoreThanException;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Scanner;
import java.util.Set;
public class Tool {
//字符串输入
public static String inputString() {
while (true) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (s.equals("")) {
System.out.println("不能为空,请重新输入");
continue;
}
return s;
}
}
//数字输入
public static int inputInt() {
while (true) {
try {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
return a;
} catch (Exception e) {
System.out.println("请输入数字");
}
}
}
//性别输入
public static String inputSex() {
while (true) {
String s = inputString();
if (s.equals("男")) {
return s;
} else if (s.equals("女")) {
return s;
} else {
System.out.println("请不要输入与性别无关的东西");
System.out.println("请重新输入");
}
}
}
//年龄输入
public static int inputAge() {
while (true) {
int a = inputInt();
if (a > 0 && a < 120) {
return a;
} else {
System.out.println("不是正常人的年龄,请重新输入");
}
}
}
//电话输入
public static String inputTel() {
while (true) {
String s = inputString();
try {
long n = Long.valueOf(s);
if (s.length() == 11) {
return s;
} else {
System.out.println("电话为十一位数字,请重新输入");
}
} catch (Exception e) {
System.out.println("电话为十一位数字,请重新输入");
}
}
}
//注册账号时判断账号是否存在等信息
public static String isAccount(Properties propPeople, ArrayList<User> users) throws MoreThanException {
int a = 0;
while (true) {
if (a >= 5) {
throw new MoreThanException();
}
a++;
String s = inputString();
if (propPeople.getProperty(s) == null) {
System.out.println("账号不在名单上,请重新输入");
continue;
}
boolean flag = false;
for (User user : users) {
if (user.getUid().equals(s)) {
System.out.println("账号已存在,请重新输入");
flag = true;
}
}
if (flag) {
continue;
}
return s;
}
}
//注册时判断姓名是否是账号的姓名
public static String isName(String s1, Properties propPeople) throws MoreThanException {
int a = 0;
while (true) {
if (a >= 5) {
throw new MoreThanException();
}
a++;
String s = inputString();
if (s.equals(propPeople.getProperty(s1))) {
return s;
} else {
System.out.println("与预留姓名不符,请重新输入");
}
}
}
//修改年龄
public static int changeAge() {
while (true) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (s.equals("")) {
return -1;
} else {
try {
int a = Integer.parseInt(s);
if (a > 0 && a < 120) {
return a;
} else {
System.out.println("不是正常人的年龄,请重新输入");
}
} catch (Exception e) {
System.out.println("请输入数字");
}
}
}
}
//修改性别
public static String changeSex() {
while (true) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (s.equals("")) {
return s;
}
if (s.equals("男")) {
return s;
} else if (s.equals("女")) {
return s;
} else {
System.out.println("请不要输入与性别无关的东西");
System.out.println("请重新输入");
}
}
}
//修改电话
public static String ChangeTel() {
while (true) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (s.equals("")) {
return s;
}
try {
long n = Long.valueOf(s);
if (s.length() == 11) {
return s;
} else {
System.out.println("电话为十一位数字,请重新输入");
}
} catch (Exception e) {
System.out.println("电话为十一位数字,请重新输入");
}
}
}
//修改院系
public static String changeDepartment() {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
return s;
}
//写入peopleAccountManagement(修改)
public static void intPeopleAccountManagement(ArrayList<User> users) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccountManagement"));
String s = null;
for (User user : users) {
if (s == null) {
s = user.getUid() + "," + user.getPassword() + "," + user.getUsername() + "," + user.getAge() + "," + user.getSex() + "," + user.getPhone() + "," + user.getDepartment() + "," + user.getRegistrationDate() + "\r\n";
} else {
s = s + user.getUid() + "," + user.getPassword() + "," + user.getUsername() + "," + user.getAge() + "," + user.getSex() + "," + user.getPhone() + "," + user.getDepartment() + "," + user.getRegistrationDate() + "\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
//兼职等级录入
public static int inLeval() {
while (true) {
try {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a >= 1 && a <= 5) {
return a;
} else {
System.out.println("等级为1-5,请重新输入:");
}
} catch (Exception e) {
System.out.println("等级为1-5,请重新输入:");
}
}
}
//信用等级修改
public static int changeBelieve() {
while (true) {
try {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a >= 0 && a <= 5) {
return a;
} else {
System.out.println("等级为0-5,请重新输入:");
}
} catch (Exception e) {
System.out.println("等级为0-5,请重新输入:");
}
}
}
//兼职人数录入
public static int inPeople() {
while (true) {
try {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a > 0 && a <= 10) {
return a;
} else if (a > 10) {
System.out.println("最多为10,请重新输入:");
} else {
System.out.println("输入错误,请重新输入:");
}
} catch (Exception e) {
System.out.println("请输入数字:");
}
}
}
//兼职类型输入
public static String inType(Properties propJob) {
Set<String> strings = propJob.stringPropertyNames();
int b=strings.size();
for(int a=1;a<=b;a++){
System.out.println(a+":"+propJob.getProperty(a+""));
}
int c=inTypeInt(b);
return propJob.getProperty(c+"");
}
//兼职类型输入数字
public static int inTypeInt(int b){
while (true) {
try {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a >= 1 && a <= b) {
return a;
} else {
System.out.println("超出范围,请重新输入:");
}
} catch (Exception e) {
System.out.println("请按规定输入数字:");
}
}
}
//兼职时间录入
public static String inTime(){
int a=inPeople();
return a+"天";
}
//兼职信息投放录入文件
public static void jobInFile(String s) throws IOException {
BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobManagement",true));
bufferedWriter.write(s);
bufferedWriter.write("\r\n");
bufferedWriter.close();
}
//兼职工作薪水录入
public static double inMoney(){
while (true) {
try {
Scanner sc = new Scanner(System.in);
double a=sc.nextDouble();
if(a<0){
System.out.println("不可为负");
}else{
return a;
}
} catch (Exception e) {
System.out.println("请按规定输入数字:");
}
}
}
//兼职逾期扣除比例录入
public static String inDeduct(){
while (true){
try {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int a=s.length();
if(s.charAt(a-1)=='%'){
String s1=s.substring(0,a-1);
// System.out.println(s1);
double b=Double.valueOf(s1);
if(b<0){
System.out.println("不能为负");
continue;
}else if(b>200){
System.out.println("不能大于薪资两倍");
continue;
}else{
return s;
}
}else {
System.out.println("格式不对,请重新输入");
}
}catch (Exception e){
System.out.println("格式不对,请重新输入");
}
}
}
//兼职信息打印
public static void showJobInformation(ArrayList<JobInformation> jobInformations){
int sum=1;
for(JobInformation s:jobInformations){
System.out.println("临时编号:"+sum+" "+s.toString());
sum++;
}
// int a=jobInformations.size();
// for(int b=0;b<a;b++){
// System.out.println(jobInformations.get(b).toString());
// }
}
//兼职信息写入文件jobManagement中
public static void inJobManagement(ArrayList<JobInformation> jobInformations) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobManagement"));
String s = null;
for (JobInformation u : jobInformations) {
if (s == null) {
s =u.getJobId()+","+u.getCompany_name()+","+u.getJob_name()+","+u.getJobtype_name()+","+u.getJob_level()+","+u.getWorkContent()+","+u.getNeedPeople()+","+u.getJob_time()+","+u.getSalary()+","+u.getDeduct_salary()+"\r\n";
} else {
s = s + u.getJobId()+","+u.getCompany_name()+","+u.getJob_name()+","+u.getJobtype_name()+","+u.getJob_level()+","+u.getWorkContent()+","+u.getNeedPeople()+","+u.getJob_time()+","+u.getSalary()+","+u.getDeduct_salary()+"\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
//用户信息写入文件peopleAll中
public static void inPeopleAll(ArrayList<UserAccount> userAll) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAll"));
String s = null;
for (UserAccount u:userAll) {
if (s == null) {
s = u.getAccountId()+","+u.getCredit_rating()+","+u.getBalance()+"\r\n";
} else {
s = s + u.getAccountId()+","+u.getCredit_rating()+","+u.getBalance()+"\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
//是否
public static boolean YOrN(){
while (true){
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
if(s.equals("Y")||s.equals("y")){
return true;
}else if (s.equals("N")||s.equals("n")){
return false;
}else{
System.out.println("输入错误,请重新输入:");
}
}
}
//添加用户ID
public static String addUser(){
while (true){
try {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
long a=Long.valueOf(s);
if(a>=100000000000l&&a<=999999999999l){
return s;
}else {
System.out.println("输入不符合规定,请重新输入:");
System.out.println("提示:用户ID大于等于一千亿,小于等于九千九百九十九亿九千九百九十九万九千九百九十九");
}
}catch (Exception e){
System.out.println("请输入数字:");
System.out.println("提示:用户ID大于等于一千亿,小于等于九千九百九十九亿九千九百九十九万九千九百九十九");
}
}
}
//添加管理员ID
public static String addAdministrator(){
while (true){
try {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
long a=Long.valueOf(s);
if(a>=0&&a<=9999){
return s;
}else {
System.out.println("输入不符合规定,请重新输入:");
System.out.println("提示:管理员ID大于等于零,小于等于九千九百九十九");
}
}catch (Exception e){
System.out.println("请输入数字:");
System.out.println("提示:管理员ID大于等于零,小于等于九千九百九十九");
}
}
}
//判断是否已经有兼职了
public static boolean alreadyJob(String s,ArrayList<String> jobAll,ArrayList<String> jobButFinish){
int a=0,b=0;
for(String u:jobAll){
String[] c=u.split(",");
String[] cc=c[0].split(":");
if(cc[1].equals(s)){
a++;
}
}
for(String u:jobButFinish){
String[] c=u.split(",");
String[] cc=c[0].split(":");
if(cc[1].equals(s)){
b++;
}
}
if(a>b){
return true;
}else {
return false;
}
}
//写入所有用户工作信息
public static void inAllJob(ArrayList<String> jobAll) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobAll"));
String s = null;
for (String u : jobAll) {
if (s == null) {
s =u+"\r\n";
} else {
s = s + u+"\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
//写入逾期的用户信息
public static void inJobButOverTime(ArrayList<String> jobAll) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButOverTime"));
String s = null;
for (String u : jobAll) {
if (s == null) {
s =u+"\r\n";
} else {
s = s + u+"\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
//写入已经完成的用户信息
public static void inJobButFinish(ArrayList<String> jobAll) throws IOException {
BufferedWriter bufferedReader = new BufferedWriter(new FileWriter("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButFinish"));
String s = null;
for (String u : jobAll) {
if (s == null) {
s =u+"\r\n";
} else {
s = s + u+"\r\n";
}
}
bufferedReader.write(s);
bufferedReader.flush();
bufferedReader.close();
}
}
2.2.3 view
2.2.3.1 administrator
2.2.3.1.1AdministratorTotalMenu
package xuexi.java.guanka16Restart1.view.administrator;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.function.Basic_Information_Management;
import xuexi.java.guanka16Restart1.service.function.System_Management;
import xuexi.java.guanka16Restart1.service.tool.Tool;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Scanner;
//管理员总菜单
public class AdministratorTotalMenu {
System_Management system_management=new System_Management();
Basic_Information_Management basic_information_management=new Basic_Information_Management();
//管理员界面设计
//proPeople:预留的账号
//proJob:预留的兼职类型
//users:存放已经注册的用户信息
//jobInformations:存放已经投放的工作信息
//userAll:存放学生编号,信用等级和余额
public void interfaceDesign(String s,Properties propPeople, Properties propJob, ArrayList<User> users, ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll,ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime) throws IOException {
while (true){
System.out.println("================欢迎来到管理员界面===============");
System.out.println("1.基本信息维护");
System.out.println("2.兼职信息投放");
System.out.println("3.系统管理");
System.out.println("4.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":myInformation(propJob,jobInformations,userAll);break;
case "2":putJobInformation(jobInformations,propJob);break;
case "3":systemManagement(s,propPeople, propJob,users,jobInformations,jobButFinish,jobButOverTime);break;
case "4":return;
default:
System.out.println("输入错误,请重新输入");
break;
}
}
}
//基本信息维护
public void myInformation(Properties propJob, ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll) throws IOException {
while (true){
System.out.println("================基本信息维护界面================");
System.out.println("1.兼职等级设置");
System.out.println("2.兼职类型设置");
System.out.println("3.用户信用调整");
System.out.println("4.逾期费用扣除比例");
System.out.println("5.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":basic_information_management.setJobLevel(jobInformations);break;
case "2":basic_information_management.setJobType(propJob,jobInformations);break;
case "3":basic_information_management.setPeopleBelieve(userAll);break;
case "4":basic_information_management.setOverdueMoney(jobInformations);break;
case "5":return;
default:
System.out.println("输入错误,请重新输入");
break;
}
}
}
//兼职信息投放
public void putJobInformation(ArrayList<JobInformation> jobInformations,Properties propJob) throws IOException {
// while (true){
// System.out.println("================兼职投放界面================");
// System.out.println("1.职位所需人员设置");
// System.out.println("2.职位金额设置");
// System.out.println("3.兼职信息录入");
// System.out.println("4.兼职时间录入");
// System.out.println("5.退出");
// System.out.println("请选择:");
// Scanner sc=new Scanner(System.in);
// String a=sc.nextLine();
// switch (a){
// case "1":put_job_information_management.setJobPeople();break;
// case "2":put_job_information_management.setJobMoney();break;
// case "3":put_job_information_management.jobInformation();break;
// case "4":put_job_information_management.jobTime();break;
// case "5":return;
// default:
// System.out.println("输入错误,请重新输入");
// break;
// }
// }
// private String jobId;//营业执照编号
// private String company_name;//工作名字
// private String job_name;//岗位名称
// private String jobtype_name;//兼职类型
// private String job_level;//兼职等级
// private String salary;//工作内容
// private String deduct_salary;//需求人数
// private String job_time;//工作时间
System.out.println("请输入营业执照编号:");
String s1= Tool.inputString();
System.out.println("请输入公司名字:");
String s2= Tool.inputString();
System.out.println("请输入岗位名称:");
String s3= Tool.inputString();
System.out.println("请选择兼职类型:");
String s4= Tool.inType(propJob);
System.out.println("请输入兼职等级:");
int s5= Tool.inLeval();
System.out.println("请输入工作内容:");
String s6= Tool.inputString();
System.out.println("请输入需求人数:");
int s7= Tool.inPeople();
System.out.println("请输入工作时间:");
String s8= Tool.inTime();
System.out.println("请输入工作薪水:");
double s9=Tool.inMoney();
System.out.println("请输入逾期扣除比例(例:3%):");
String s10=Tool.inDeduct();
jobInformations.add(new JobInformation(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10));
String s=s1+","+s2+","+s3+","+s4+","+s5+","+s6+","+s7+","+s8+","+s9+","+s10;
Tool.jobInFile(s);
}
//系统管理
//管理员界面设计
//proPeople:预留的账号
//proJob:预留的兼职类型
//users:存放已经注册的用户信息
//jobInformations:存放已经投放的工作信息
//userAll:存放学生编号,信用等级和余额
public void systemManagement(String s,Properties propPeople, Properties propJob, ArrayList<User> users, ArrayList<JobInformation> jobInformations,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime) throws IOException {
while (true){
System.out.println("================系统管理界面================");
System.out.println("1.删除管理员账号");
System.out.println("2.删除用户账号");
System.out.println("3.兼职信息删除");
System.out.println("4.添加用户账号");
System.out.println("5.添加管理员账号");
System.out.println("6.修改密码");
System.out.println("7.查询所有用户信息");
System.out.println("8.查询管理员信息");
System.out.println("9.查询已经投放的职位信息");
System.out.println("10.查询已完成职位");
System.out.println("11.查询逾期兼职信息");
System.out.println("12.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":system_management.deleteAdministrator(s,users);break;
case "2":system_management.deletePeople(users);break;
case "3":system_management.deleteJob(jobInformations);break;
case "4":system_management.addPeople(propPeople);break;
case "5":system_management.addAdministrator(propPeople);break;
case "6":system_management.changePassword(s,users);break;
case "7":system_management.seeAllPeople(users);break;
case "8":system_management.seeAllAdministrator(users);break;
case "9":system_management.seeAllPutJob(jobInformations);break;
case "10":system_management.seeAllFinishJob(jobButFinish);break;
case "11":system_management.seeAllOverdueJob(jobButOverTime);break;
case "12":return;
default:
System.out.println("输入错误,请重新输入");
break;
}
}
}
}
2.2.3.2 people
2.2.3.2.1 PeopleTotalMenu
package xuexi.java.guanka16Restart1.view.people;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.function.Job_Apply_Management;
import xuexi.java.guanka16Restart1.service.function.Personal_Information_Management;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Scanner;
//用户总菜单
public class PeopleTotalMenu {
Personal_Information_Management personal_information_management=new Personal_Information_Management();
Job_Apply_Management job_apply_management=new Job_Apply_Management();
//用户界面设计
//管理员界面设计
//proPeople:预留的账号
//proJob:预留的兼职类型
//users:存放已经注册的用户信息
//jobInformations:存放已经投放的工作信息
//userAll:存放学生编号,信用等级和余额
//s:账号,用来标识这个账户
public void interfaceDesign(String s,Properties propPeople, Properties propJob, ArrayList<User> users, ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll,ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime,Properties jobWorking) throws IOException, ParseException {
while (true){
System.out.println("================欢迎来到用户界面================");
int mark = 0;
//查询得到自己的信用
for(UserAccount u:userAll){
if(u.getAccountId().equals(s)){
mark=u.getCredit_rating();
}
}
if(mark==0){
System.out.println("您的信用为0,没有权限");
return;
}
System.out.println("1.个人信息管理");
System.out.println("2.兼职申请");
System.out.println("3.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":myinformation(s,users,userAll);break;
case "2":jobApply(s,jobInformations,userAll,jobAll,jobButFinish,jobButOverTime,jobWorking);break;
case "3":return;
default:
System.out.println("输入错误,请重新选择");
break;
}
}
}
//个人信息管理
public void myinformation(String s,ArrayList<User> users,ArrayList<UserAccount> userAll) throws IOException {
while (true){
System.out.println("================个人信息管理界面================");
System.out.println("1.个人信息修改");
System.out.println("2.修改密码");
System.out.println("3.查询信用等级");
System.out.println("4.查询余额");
System.out.println("5.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":personal_information_management.informationChange(s,users);break;
case "2":personal_information_management.peopleChangePassword(s,users);break;
case "3":personal_information_management.seePeopleLevel(s,userAll);break;
case "4":personal_information_management.seeMoney(s,userAll);break;
case "5":return;
default:
System.out.println("输入错误,请重新选择");
break;
}
}
}
//兼职申请模块(用户)
public void jobApply(String s, ArrayList<JobInformation> jobInformations,ArrayList<UserAccount> userAll,ArrayList<String> jobAll,ArrayList<String> jobButFinish,ArrayList<String> jobButOverTime,Properties jobWorking) throws IOException, ParseException {
while(true){
System.out.println("================兼职申请界面================");
System.out.println("1.查询所有的职位信息");
System.out.println("2.只查询自己能够申请的职位信息");
System.out.println("3.查询已经完成过的兼职信息");
System.out.println("4.查询正在完成的兼职信息");
System.out.println("5.兼职申请");
System.out.println("6.结束工作");
System.out.println("7.退出");
System.out.println("请选择:");
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
switch (a){
case "1":job_apply_management.seeAllJob(jobInformations);break;
case "2":job_apply_management.seeSomeJob(s,jobInformations,userAll);break;
case "3":job_apply_management.seeAllFinishJob(s,jobButFinish);break;
case "4":job_apply_management.seeMySomeJob(s,jobWorking);break;
case "5":job_apply_management.openJob(s,jobInformations,userAll,jobAll,jobButFinish,jobWorking);break;
case "6":job_apply_management.closeJob(s,jobAll,jobButFinish,jobButOverTime,jobWorking,userAll);break;
case "7":return;
default:
System.out.println("输入错误,请重新选择");
break;
}
}
}
}
2.2.3.3 Test1
package xuexi.java.guanka16Restart1.view;
import xuexi.java.guanka16Restart1.domin.JobInformation;
import xuexi.java.guanka16Restart1.domin.User;
import xuexi.java.guanka16Restart1.domin.UserAccount;
import xuexi.java.guanka16Restart1.service.ExceptionTest.MoreThanException;
import xuexi.java.guanka16Restart1.service.function.LoginAndRegistration;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Properties;
public class Test1 {
public static void main(String[] args) throws IOException, MoreThanException, ParseException {
//可注册账号导入
Properties propPeople=new Properties();
FileReader fr = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccount");
propPeople.load(fr);
fr.close();
//兼职类型导入
Properties propJob=new Properties();
FileReader fr1 = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\job");
propJob.load(fr1);
fr1.close();
//存放账号信息
ArrayList<User> users=new ArrayList<>();
BufferedReader bufferedReader=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAccountManagement"));
String line;
while((line=bufferedReader.readLine())!=null){
String[] c=line.split(",");
users.add(new User(c[0],c[1],c[2],Integer.valueOf(c[3]),c[4],c[5],c[6],c[7]));
}
bufferedReader.close();
//存放工作信息
ArrayList<JobInformation> jobInformations=new ArrayList<>();
BufferedReader bufferedReader1=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobManagement"));
while ((line=bufferedReader1.readLine())!=null){
String[] c=line.split(",");
jobInformations.add(new JobInformation(c[0],c[1],c[2],c[3],Integer.valueOf(c[4]),c[5],Integer.valueOf(c[6]),c[7],Double.valueOf(c[8]),c[9]));
}
bufferedReader1.close();
//存放用户等级,余额
ArrayList<UserAccount> userAll=new ArrayList<>();
BufferedReader bufferedReader2=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\peopleAll"));
while ((line=bufferedReader2.readLine())!=null){
String[] c=line.split(",");
userAll.add(new UserAccount(c[0],Integer.valueOf(c[1]),Double.valueOf(c[2])));
}
bufferedReader2.close();
//存放所有用户的工作信息
// Properties jobAll=new Properties();
// FileReader fr2 = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobAll");
// jobAll.load(fr2);
// fr2.close();
ArrayList<String> jobAll=new ArrayList<>();
BufferedReader bufferedReader3=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobAll"));
while ((line=bufferedReader3.readLine())!=null){
jobAll.add(line);
}
bufferedReader3.close();
//存放用户已完成的工作信息
// Properties jobButFinish=new Properties();
// FileReader fr3 = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButFinish");
// jobButFinish.load(fr3);
// fr3.close();
ArrayList<String> jobButFinish=new ArrayList<>();
BufferedReader bufferedReader4=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButFinish"));
while ((line=bufferedReader4.readLine())!=null){
jobButFinish.add(line);
}
bufferedReader4.close();
//存放用户已逾期的工作信息
// Properties jobButOverTime=new Properties();
// FileReader fr4 = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButOverTime");
// jobButOverTime.load(fr4);
// fr4.close();
ArrayList<String> jobButOverTime=new ArrayList<>();
BufferedReader bufferedReader5=new BufferedReader(new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobButOverTime"));
while ((line=bufferedReader5.readLine())!=null){
jobButOverTime.add(line);
}
bufferedReader5.close();
//存放用户正在进行的工作信息
Properties jobWorking=new Properties();
FileReader fr5 = new FileReader("E:\\study\\IDEA\\javaProject\\javaProjectCS\\javatest1\\src\\xuexi\\java\\guanka16Restart1\\file\\jobWorking");
jobWorking.load(fr5);
fr5.close();
//
// //测试
// Tool.inType(propJob);
//传入数据,开启程序
LoginAndRegistration loginAndRegistration=new LoginAndRegistration();
loginAndRegistration.login(propPeople,propJob,users,jobInformations,userAll,jobAll,jobButFinish,jobButOverTime,jobWorking);
System.out.println("测试成功,下班");
}
}
三、部分功能运行结果