需求说明:
- 据了解,目前在校大学生80%以上有做兼职的需求,兼职打工已经不仅仅是经济困难的学生赚取生活费用的途径。调查显示,全球经济危机对就业产生冲击,用人单位对人员的社会实践能力要求提高,大学期间必要的社会实践既可以提高能力,又为适应社会,减轻家庭经济负担起到了积极的作用;社会中虚假兼职机构、欺骗性中介机构充斥,真伪难辨,学生受骗事件频发,极大的损害了学生的经济利益,甚至对学生的人生安全造成威胁。从校园踏入社会,兼职只是一段小小的插曲,通过兼职丰富阅历、增长社会经验固然是好事,可是毫无戒备的步入社会,不仅会事与愿违,还可能造成不必要的损所以。所以,我们需求设计一个校园兼职平台来方便在校学生找兼职。
- 本平台根据角色定位不同有不同的模块,首先系统有一个登录注册模块,属于兼职人员的模块有个人信息管理和兼职申请;属于管理员的模块有基本信息维护、兼职信息投放和系统管理。
- 平台登录注册:用户可以通过账号密码登录平台,如果用户是第一次使用该平台,则可以通过注册方式完成信息录入。平台根据用户输入的账号密码,判断该用户的角色是兼职人员还是管理员,展示不同的操作界面。如果用户忘记密码,可以通过自己的账号和注册时录入的真实姓名找回密码。
- 个人信息管理:能够对用户的基本信息进行管理,包括个人信息的修改,如学生转到别的专业,此时要修改学生的基本信息;修改密码,为了账户的安全性,可以修改用户的密码。查询信用等级,比如有一个用户一开始可以完成兼职等级最高的工作,但是在这次工作中,未能按时完成工作,于是管理员降低了该用户的信用等级,该用户就不能接高级的兼职工作了。查询余额,用户每次按时完成兼职能得到一笔费用,有逾期会扣除一部分佣金,最后得到总的余额。
- 兼职申请模块:用户能够查询所有的职位信息,因为信用等级的限制,用户也可以只查询自己能够申请的职位信息。查询到合适的职位用户可以直接申请,申请后到达工作截至时间前完成工作可以提前结束工作得到佣金,如果逾期后完成,管理员会调整用户的信用等级。用户可以查询自己已经完成过的兼职信息和自己正在完成的兼职信息。
- 基本信息维护模块:管理员能够根据用户完成兼职的情况动态的调整用户的兼职等级状态。管理员可以调整兼职的等级,供用户选择。管理员能够根据兼职的等级不同设置逾期费用扣除比例,比如最高级的兼职逾期一天扣10元,扣除兼职费用后继续扣除用户余额,直到用户余额为0,自动结束工作,结算费用。
- 兼职信息投放:管理员可以把所有公司的兼职招聘信息发布到网上,根据公司的需求设置岗位所需人员,工资以及兼职的时间段,比如发传单,这份兼职需要周一到周五的上午9点至11点工作,那么在这个时间段已经有了其他工作的用户就不能申请该工作。
- 系统管理模块:管理员能够删除管理员账户,也能删除平台用户以及一些完成过的兼职信息。管理员能够添加平台用户信息到系统,本平台是针对学生的软件,所以能够注册的只能是学生,所以平台需要提前将学生信息录入系统,用户才能注册账号,如果未能及时录入信息照成无法注册,那么就需要联系管理员进行信息录入。管理员可以添加其他的管理员账户,为了安全起见,管理员和普通用户一样能够修改密码。管理员还能够查询所有的用户信息、管理员账户信息、已经投放的职位信息、已经完成的兼职信息和已经逾期的兼职信息。
具体实现:
Interfaceview类实现:
public class Interfaceview {
Interfacemethod interfacemethod = new Interfacemethod();
PartTimeJobView parttimejobview = new PartTimeJobView();
AdministratorsView administratorsthod = new AdministratorsView();
public Interfaceview() throws InterruptedException, IOException, ClassNotFoundException {
}
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException, ParseException {
Interfaceview interfaceview = new Interfaceview();
interfaceview.method();
}
public void method() throws IOException, ClassNotFoundException, InterruptedException, ParseException {
String login;
boolean flag = true;
while (flag){
System.out.println("****欢迎来到校园兼职平台系统****");
System.out.println("1.用户登入");
System.out.println("2.用户注册");
System.out.println("3.忘记密码");
System.out.println("4.退出系统");
System.out.println("请选择:");
char ch1 = TSUtility.readMenuSelection();
switch (ch1){
case '1':
interfacemethod.Login();
break;
case '2':
interfacemethod.register();
break;
case '3':
interfacemethod.changepassword();
break;
case '4':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
System.exit(0);
}
break;
}
}
}
public void parttimejob() throws IOException, ClassNotFoundException, InterruptedException, ParseException {
boolean flag = true;
while (flag){
System.out.println("** 欢迎来到兼职人员界面 **");
System.out.println("** 1.个人信息管理 **");
System.out.println("** 2.兼职申请 **");
System.out.println("** 3.退出系统 **");
System.out.println("请选择:");
char ch2 = TSUtility.readMenuSelection3();
switch (ch2){
case '1':
parttimejobview.information();
break;
case '2':
parttimejobview.job_apply();
break;
case '3':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
System.exit(0);
}
break;
}
}
}
public void administrators() throws IOException, ClassNotFoundException, ParseException, InterruptedException {
boolean falg2 =true;
while (falg2){
System.out.println("** 欢迎来到管理员界面 **");
System.out.println("** 1.基本信息维护 **");
System.out.println("** 2.兼职信息投放 **");
System.out.println("** 3.系统管理 **");
System.out.println("** 4.退出系统 **");
System.out.println("请选择:");
char ch3 = TSUtility.readMenuSelection();
switch (ch3){
case '1':
administratorsthod.maintenance();
break;
case '2':
administratorsthod.informationdelivery();
break;
case '3':
administratorsthod.systemmanagement();
break;
case '4':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
System.exit(0);
}
break;
}
}
}
}
AdministratorsView类实现:
public class AdministratorsView {
InformationDeliverymethod informationDeliverymethod = new InformationDeliverymethod();
InformationMaintenancemethod informationmaintenancemethod = new InformationMaintenancemethod();
SystemManagementmethod systemmanagementmethod = new SystemManagementmethod();
Interfacemethod interfacemethod = new Interfacemethod();
public AdministratorsView() throws InterruptedException, IOException, ClassNotFoundException {
}
public void maintenance() throws IOException, ClassNotFoundException {//基本信息维护
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("** 请选择:");
char ch1 = TSUtility.readMenuSelectionPro();
switch (ch1){
case '1':
informationmaintenancemethod.level_setting();
break;
case '2':
informationmaintenancemethod.type_settings();
break;
case '3':
informationmaintenancemethod.credit_settings();
break;
case '4':
informationmaintenancemethod.overdue_setting();
break;
case '5':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void informationdelivery() throws IOException, ClassNotFoundException { //兼职信息投放方法
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("** 请选择:");
char ch2 = TSUtility.readMenuSelectionPro();
switch (ch2){
case '1':
informationDeliverymethod.personnel();
break;
case '2':
informationDeliverymethod.money_settings();
break;
case '3':
informationDeliverymethod.Information_entry();
break;
case '4':
informationDeliverymethod.time_change();
break;
case '5':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void systemmanagement() throws IOException, ClassNotFoundException, InterruptedException, 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("** 请选择:");
char ch3 = TSUtility.readMenuSelectionPro();
switch (ch3){
case '1':
delete();
break;
case '2':
addto();
break;
case '3':
query();
break;
case '4':
interfacemethod.changepassword();
break;
case '5':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void delete() throws IOException, ClassNotFoundException { //删除操作方法
while (true){
System.out.println("** 欢迎来到删除操作界面 **");
System.out.println("** 1.删除账户 **");
System.out.println("** 2.删除用户 **");
System.out.println("** 3.删除兼职信息 **");
System.out.println("** 4.退出 **");
System.out.println("** 请选择:");
char ch4 = TSUtility.readMenuSelection();
switch (ch4){
case '1':
systemmanagementmethod.delete_account();
break;
case '2':
systemmanagementmethod.delete_user();
break;
case '3':
systemmanagementmethod.delete_work();
break;
case '4':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void addto() throws IOException, ClassNotFoundException, InterruptedException { //添加操作方法
while (true){
System.out.println("** 欢迎来到添加操作界面 **");
System.out.println("** 1.添加学生信息");
System.out.println("** 2.添加用户 **");
System.out.println("** 3.添加账户 **");
System.out.println("** 4.退出 **");
System.out.println("** 请选择:");
char ch5 = TSUtility.readMenuSelection();
switch (ch5){
case '1':
systemmanagementmethod.add_information();
break;
case '2':
systemmanagementmethod.add_user();
break;
case '3':
systemmanagementmethod.add_account();
break;
case '4':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void query() throws IOException, ClassNotFoundException, 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("** 请选择:");
char ch6 = TSUtility.readMenuSelection6();
switch (ch6){
case '1':
systemmanagementmethod.query_user();
break;
case '2':
systemmanagementmethod.query_account();
break;
case '3':
systemmanagementmethod.positions_placed();
break;
case '4':
systemmanagementmethod.completed_position();
break;
case '5':
systemmanagementmethod.overdue_information();
break;
case '6':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
}
PartTimeJobView类实现:
public class PartTimeJobView { //个人信息管理界面和兼职申请界面
PartTimeJobmethod parttimejobmethod= new PartTimeJobmethod();
Interfacemethod interfacemethod = new Interfacemethod();
Job_Applymethod job_applymethod = new Job_Applymethod();
public PartTimeJobView() throws InterruptedException, IOException, ClassNotFoundException {
}
public void information() throws IOException, ClassNotFoundException, InterruptedException {
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("请选择:");
char ch = TSUtility.readMenuSelectionPro();
switch (ch){
case '1':
parttimejobmethod.modify();
break;
case'2':
interfacemethod.changepassword();
break;
case '3':
parttimejobmethod.query_grade();
break;
case '4':
parttimejobmethod.query_balance();
break;
case '5':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return;
}
break;
}
}
}
public void job_apply() throws IOException, ClassNotFoundException, ParseException {
boolean flag= true;
while (flag){
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("请选择:");
char ch = TSUtility.readMenuSelection7();
switch (ch){
case '1':
job_applymethod.query_all_job();
break;
case '2':
job_applymethod.query_can_apply();
break;
case '3':
job_applymethod.job_application();
break;
case '4':
job_applymethod.end_job();
break;
case '5':
job_applymethod.Completed_job();
break;
case '6':
job_applymethod.to_be_completed();
break;
case '7':
System.out.println("确定要退出吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
flag =false;
}
break;
}
}
}
}
InformationDeliverymethod类实现:
public class InformationDeliverymethod { //兼职信息投放方法
public void Information_entry() throws IOException, ClassNotFoundException { //兼职信息录入方法
System.out.println("录入兼职相关信息");
System.out.println("请输入");
System.out.println("公司营业执照编号:");
String JID = TSUtility.readKeyBoard(18, false);
System.out.println("公司名字");
String company_name = TSUtility.readKeyBoard(15, false);
File file = new File("Level16\\src\\file\\job.txt");
if(file.length() < 10){
System.out.println("岗位名称");
String job_name = TSUtility.readKeyBoard(15, false);
String jobtype_name = "";
boolean flag = true;
while (flag){
System.out.println("兼职类型");
System.out.println("可添加类型:(前端、开发、户外)");
jobtype_name = TSUtility.readKeyBoard(2, false);
if(jobtype_name.equals("开发")){
break;
}else if(jobtype_name.equals("前端")){
break;
}else if(jobtype_name.equals("户外")){
break;
}else {
System.out.println("你输入的类型有误");
}
}
System.out.println("兼职等级");
String job_level = TSUtility.readKeyBoard(1, false);
System.out.println("需求人数");
String job_content = TSUtility.readKeyBoard(2, false);
System.out.println("工作内容");
String job_demand = TSUtility.readKeyBoard(20, false);
System.out.println("工作时间(天数)");
String job_time = TSUtility.readKeyBoard(2, false);
String job_section ="";
while (true){
System.out.println("最晚开始工作时间(如:2022-10-01,2022年日期):");
job_section = TSUtility.readKeyBoard(10, false);
Calendar c = Calendar.getInstance();
int year1 = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH)+1;
int date1 = c.get(Calendar.DATE);
String[] st = job_section.split("-");
if(Integer.parseInt(st[0]) == year1){
if(Integer.parseInt(st[1]) >month1 && Integer.parseInt(st[1]) <= 12 ){
if (Integer.parseInt(st[2]) <= 31 ){
break;
}
}else if (Integer.parseInt(st[1]) == month1 ){
if (Integer.parseInt(st[2]) > date1 && Integer.parseInt(st[2]) <= 31 ){
break;
}
}
}
}
Job job = new Job(JID,company_name,job_name,jobtype_name,job_level,job_content,job_demand,job_time,job_section);
ArrayList<Job> arrjob =new ArrayList<>();
arrjob.add(job);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("添加成功");
}else{
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
for (int i =0 ; i <arrjob.size(); i++){
if(arrjob.get(i).getJID().equals(JID)) {
System.out.println("该公司编号已经注册过了");
return;
}else {
if(arrjob.get(i).getCompany_name().equals(company_name)){
System.out.println("该公司名称已经注册过了");
return;
}
}
}
System.out.println("岗位名称");
String job_name = TSUtility.readKeyBoard(15, false);
String jobtype_name = "";
boolean flag = true;
while (flag){
System.out.println("兼职类型");
System.out.println("可添加类型:(前端、开发、户外)");
jobtype_name = TSUtility.readKeyBoard(2, false);
if(jobtype_name.equals("开发")){
break;
}else if(jobtype_name.equals("前端")){
break;
}else if(jobtype_name.equals("户外")){
break;
}else {
System.out.println("你输入的类型有误");
}
}
System.out.println("兼职等级");
String job_level = TSUtility.readKeyBoard(1, false);
System.out.println("需求人数");
String job_content = TSUtility.readKeyBoard(2, false);
System.out.println("工作内容");
String job_demand = TSUtility.readKeyBoard(20, false);
System.out.println("工作时间");
String job_time = TSUtility.readKeyBoard(2, false);
String job_section ="";
while (true){
System.out.println("最晚开始工作时间(如:2022-10-01,2022年日期):");
job_section = TSUtility.readKeyBoard(10, false);
Calendar c = Calendar.getInstance();
int year1 = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH)+1;
int date1 = c.get(Calendar.DATE);
String[] st = job_section.split("-");
if(Integer.parseInt(st[0]) == year1){
if(Integer.parseInt(st[1]) >month1 && Integer.parseInt(st[1]) <= 12 ){
if (Integer.parseInt(st[2]) <= 31 ){
break;
}
}else if (Integer.parseInt(st[1]) == month1 ){
if (Integer.parseInt(st[2]) > date1 && Integer.parseInt(st[2]) <= 31 ){
break;
}
}
}
}
Job job = new Job(JID,company_name,job_name,jobtype_name,job_level,job_content,job_demand,job_time,job_section);
arrjob.add(job);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("添加成功");
}
}
public void personnel() throws IOException, ClassNotFoundException { //兼职所需人员设置
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
boolean flag = true;
while (flag){
for (Job j :arrjob){
System.out.println(j);
}
// System.out.println(arrjob);
System.out.println("你需要对第几条工作信息的人员进行更改哪");
int num = TSUtility.readInt()-1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
System.out.println("当前"+arrjob.get(num).getCompany_name()+"公司的工作还需要"+arrjob.get(num).getJob_content()+"人");
System.out.println("变更后的人数为:");
int number = TSUtility.readInt();
if (number < 0){
System.out.println("你输入的人数有误");
continue;
}
System.out.println("确定变更吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
arrjob.get(num).setJob_content(String.valueOf(number));
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("变更成功");
flag = false;
}else {
System.out.println("未变更");
flag = false;
}
}
}
public void money_settings() throws IOException, ClassNotFoundException {//职位金额设置
System.out.println("欢迎来到职位金额设置界面");
boolean flag = true;
while (flag){
System.out.println("请输入兼职类型");
System.out.println("可添加类型:(前端、开发、户外)");
String jobtype_name = TSUtility.readKeyBoard(2, false);
if(jobtype_name.equals("开发")){
boolean shezhi = shezhi(jobtype_name);
if (shezhi){
continue;
}else {
flag = false;
}
}else if(jobtype_name.equals("前端")){
boolean shezhi = shezhi(jobtype_name);
if (shezhi){
continue;
}else {
flag = false;
}
}else if(jobtype_name.equals("户外")){
boolean shezhi = shezhi(jobtype_name);
if (shezhi){
continue;
}else {
flag = false;
}
}else {
System.out.println("你输入的类型有误");
}
}
}
public boolean shezhi(String jobtype_name) throws IOException, ClassNotFoundException {// 设置类型的JobType值
System.out.println("该类型对应的兼职类型编号为(4为数字):");
String num1 = TSUtility.readKeyBoard(4,false);
System.out.println("该类型对应的薪水(\\天)为:");
int num2 = TSUtility.readInt3();
if (pd(num2)){
System.out.println("输入的信息有误");
return false;
}
JobType jt1 = new JobType(num1,jobtype_name,String.valueOf(num2),"0.1");
File file = new File("Level16\\src\\file\\兼职类型.txt");
if (file.length() < 10){
ArrayList<JobType> arrjt = new ArrayList<>();
arrjt.add(jt1);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos.writeObject(arrjt);
oos.close();
System.out.println("设置完成");
System.out.println("还需要继续吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return true;
}else {
return false;
}
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt = (ArrayList<JobType>) ois.readObject();
ois.close();
for (JobType jt : arrjt){
if (jt.getJobtype_name().equals(jobtype_name)){
System.out.println("该类型已存在");
return true;
}
}
arrjt.add(jt1);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos.writeObject(arrjt);
oos.close();
System.out.println("设置完成");
System.out.println("还需要继续吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
return true;
}else {
return false;
}
}
}
public boolean pd(int i){
if(i <= 0){
return true;
}
return false;
}
public void time_change() throws IOException, ClassNotFoundException {//兼职时间变更
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
boolean flag = true;
while (flag) {
for (Job j : arrjob) {
System.out.println(j);
}
System.out.println("你需要对第几条工作信息的人员进行更改哪");
int num = TSUtility.readInt() - 1;
if (num < 0) {
System.out.println("你输入的信息有误");
continue;
}
System.out.println("当前" + arrjob.get(num).getCompany_name() + "最晚开始时间为:" + arrjob.get(num).getJob_section() +
",工作天数为:" + arrjob.get(num).getJob_time());
String job_section = "";
while (true) {
System.out.println("变更后的最晚开始时间为(如:2022-10-01,2022年日期):");
job_section = TSUtility.readKeyBoard(10, false);
Calendar c = Calendar.getInstance();
int year1 = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH) + 1;
int date1 = c.get(Calendar.DATE);
String[] st = job_section.split("-");
if (Integer.parseInt(st[0]) == year1) {
if (Integer.parseInt(st[1]) > month1 && Integer.parseInt(st[1]) <= 12) {
if (Integer.parseInt(st[2]) <= 31) {
break;
}
} else if (Integer.parseInt(st[1]) == month1) {
if (Integer.parseInt(st[2]) > date1 && Integer.parseInt(st[2]) <= 31) {
break;
}
}
}
}
System.out.println("变更后的工作天数为:");
String job_time = TSUtility.readKeyBoard(2, false);
System.out.println("确定变更吗(Y/N):");
char c = TSUtility.readConfirmSelection();
if (c == 'Y') {
arrjob.get(num).setJob_section(job_section);
arrjob.get(num).setJob_time(job_time);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("变更成功");
flag = false;
} else {
System.out.println("未变更");
flag = false;
}
}
}
}
InformationMaintenancemethod类实现:
public class InformationMaintenancemethod {
public void level_setting() throws IOException, ClassNotFoundException { //兼职等级设置
boolean flag = true;
while (flag){
System.out.println("欢迎来到兼职等级变更界面");
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
for (Job j : arrjob){
System.out.println(j);
}
System.out.println("您需要变更第几条信息哪");
int num = TSUtility.readInt() -1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
System.out.println("当前"+arrjob.get(num).getCompany_name()+"公司的兼职等级为"+arrjob.get(num).getJob_level());
System.out.println("您需要变更为:");
String st = TSUtility.readKeyBoard(1, false);
if (Integer.parseInt(st) < 0|| Integer.parseInt(st) > 5 ){
System.out.println("您输入的信息有误");
continue;
}
arrjob.get(num).setJob_level(st);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("变更成功");
flag = false;
}
}
public void type_settings() throws IOException, ClassNotFoundException {//兼职类型设置
System.out.println("欢迎来到兼职类型变更界面");
boolean flag = true;
while (flag){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
for (Job j : arrjob){
System.out.println(j);
}
System.out.println("你需要变更第几条信息哪");
int num = TSUtility.readInt() -1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
System.out.println("当前"+arrjob.get(num).getCompany_name()+"公司的兼职类型为:"+arrjob.get(num).getJobtype_name());
String jobtype_name = "";
boolean flag2 = true;
while (flag2){
System.out.println("你需要变更为:");
System.out.println("可添加类型:(前端、开发、户外)");
jobtype_name = TSUtility.readKeyBoard(2, false);
if(jobtype_name.equals("开发")){
break;
}else if(jobtype_name.equals("前端")){
break;
}else if(jobtype_name.equals("户外")){
break;
}else {
System.out.println("你输入的类型有误");
}
}
arrjob.get(num).setJobtype_name(jobtype_name);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("变更成功");
flag = false;
}
}
public void credit_settings() throws IOException, ClassNotFoundException {//用户信用调整
boolean flag = true;
while (flag){
System.out.println("欢迎来到用户信用变更界面");
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> arruser = (ArrayList<User>) ois.readObject();
ois.close();
for (User u : arruser){
System.out.println(u);
}
System.out.println("你需要变更第几条信息哪");
int num = TSUtility.readInt() -1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
System.out.println("当前"+arruser.get(num).getUsername()+"的信用等级为"+arruser.get(num).getCredit_rating());
System.out.println("您需要变更为:");
String st = TSUtility.readKeyBoard(1, false);
if (Integer.parseInt(st) < 0|| Integer.parseInt(st) > 5 ){
System.out.println("您输入的信息有误");
continue;
}
arruser.get(num).setCredit_rating(st);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
oos.writeObject(arruser);
oos.close();
System.out.println("变更成功");
flag = false;
}
}
public double overdue_setting() throws IOException, ClassNotFoundException {//逾期费用扣除比例
boolean flag = true;
while (flag){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> arruser = (ArrayList<User>) ois.readObject();
ois.close();
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\uid.txt"));
String line = br.readLine();
br.close();
String st ="";
for (User u : arruser){
if (u.getUID() == line){
st = u.getCredit_rating();
}
}
switch (st){
case "5":
System.out.println("你当前的信用等级为:"+st+",每天逾期扣除比例为:0.1");
return 0.1;
case "4":
ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt = (ArrayList<JobType>) ois2.readObject();
ois2.close();
for (int i =0; i < arrjt.size(); i++){
arrjt.get(i).setDeduct_salary("0.15");
}
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos.writeObject(arrjt);
oos.close();
System.out.println("你当前的信用等级为:"+st+",每天逾期扣除比例为:0.15");
return 0.15;
case "3":
ObjectInputStream ois3 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt3 = (ArrayList<JobType>) ois3.readObject();
ois3.close();
for (int i =0; i < arrjt3.size(); i++){
arrjt3.get(i).setDeduct_salary("0.2");
}
ObjectOutputStream oos3 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos3.writeObject(arrjt3);
oos3.close();
System.out.println("你当前的信用等级为:"+st+",每天逾期扣除比例为:0.2");
return 0.2;
case "2":
ObjectInputStream ois4 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt4 = (ArrayList<JobType>) ois4.readObject();
ois4.close();
for (int i =0; i < arrjt4.size(); i++){
arrjt4.get(i).setDeduct_salary("0.25");
}
ObjectOutputStream oos4 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos4.writeObject(arrjt4);
oos4.close();
System.out.println("你当前的信用等级为:"+st+",每天逾期扣除比例为:0.25");
return 0.25;
case "1":
ObjectInputStream ois5 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt5 = (ArrayList<JobType>) ois5.readObject();
ois5.close();
for (int i =0; i < arrjt5.size(); i++){
arrjt5.get(i).setDeduct_salary("0.3");
}
ObjectOutputStream oos5 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\兼职类型.txt"));
oos5.writeObject(arrjt5);
oos5.close();
System.out.println("你当前的信用等级为:"+st+",每天逾期扣除比例为:0.3");
return 0.3;
default:
System.out.println("信息有误");
flag = false;
break;
}
}
return 0.0;
}
}
Interfacemethod类实现:
public class Interfacemethod {
public Interfacemethod() throws InterruptedException, IOException, ClassNotFoundException {
}
public void register() throws IOException, ClassNotFoundException, InterruptedException { //注册方法
boolean flag =true;
while (flag){
System.out.println("请输入用户编号:");
String UID1 = TSUtility.readKeyBoard(10, false);
System.out.println("请输入真实姓名:");
String username = TSUtility.readKeyBoard(5, false);
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\systemuser.txt"));
Properties prop =new Properties();
prop.load(br);
Set<String> names = prop.stringPropertyNames();
int num = 0;
for (String key : names){
if(key.equals(UID1)){
String value = prop.getProperty(key);
if(value.equals(username)){
File file = new File("Level16\\src\\file\\user.txt");
long length = file.length();
if(length <10){
System.out.println("请输入密码:");
String password = TSUtility.readKeyBoard(10, false);
System.out.println("请输入年龄:");
String age = TSUtility.readKeyBoard(2, false);
System.out.println("请输入性别:");
String sex = TSUtility.readKeyBoard(1, false);
System.out.println("请输入手机号:");
String phone = TSUtility.readKeyBoard(20, false);
System.out.println("请输入所在院系:");
String department = TSUtility.readKeyBoard(10, false);
User user =new User(UID1,username,password,age,sex,phone,department,time(),"1","0");
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = new ArrayList<>();
array.add(user);
oos.writeObject(array);
System.out.println("创建完成");
oos.close();
flag = false;
num = 1;
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array2 = (ArrayList<User>) ois.readObject();
ois.close();
for (int i =0 ; i <array2.size(); i++){
if(array2.get(i).getUID().equals(UID1)) {
System.out.println("该用户已经注册过了");
return;
}
}
System.out.println("请输入密码:");
String password = TSUtility.readKeyBoard(10, false);
System.out.println("请输入年龄:");
String age = TSUtility.readKeyBoard(2, false);
System.out.println("请输入性别:");
String sex = TSUtility.readKeyBoard(1, false);
System.out.println("请输入手机号:");
String phone = TSUtility.readKeyBoard(20, false);
System.out.println("请输入所在院系:");
String department = TSUtility.readKeyBoard(10, false);
User user =new User(UID1,username,password,age,sex,phone,department,time(),"5","0");
array2.add(user);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
oos.writeObject(array2);
TSUtility.loadSpecialEffects();
System.out.println("创建完成");
oos.close();
flag = false;
num = 1;
}
}
else {
System.out.println("您输入的信息有误");
br.close();
num =1;
break;
}
}
}
br.close();
if (num == 0){
System.out.println("您输入的信息有误");
br.close();
}
}
}
public String UID() throws IOException { //把UID从文件中读出
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\uid.txt"));
String line ;
String line1 ="";
while ((line = br.readLine()) != null){
line1 = line;
}
br.close();
return line1;
}
public void UIDwriter(String UID) throws IOException { //把UID存入文件
// FileWriter fw = new FileWriter("Level16\\src\\file\\uid.txt");
BufferedWriter bw = new BufferedWriter(new FileWriter("Level16\\src\\file\\uid.txt"));
bw.write(UID);
bw.newLine();
bw.flush();
bw.close();
}
public void Login() throws IOException, ClassNotFoundException, InterruptedException, ParseException { //登入方法
Interfaceview interfaceview = new Interfaceview();
boolean flag= true;
int num =0;
while (flag){
System.out.println("请输入编号:");
String UID =(TSUtility.readKeyBoard(10, false)) ;
UIDwriter(UID);
System.out.println("请输入密码:");
String password = TSUtility.readKeyBoard(10, false);
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = (ArrayList<User>) ois.readObject();
ois.close();
for(User user: array){
if(user.getUID().equals(UID)){
FileWriter fw = new FileWriter("Level16\\src\\file\\uid.txt");
fw.write(UID);
fw.close();
num =1;
if(user.getPassword().equals(password)){
// TSUtility.loadSpecialEffects();
System.out.println("登入成功");
char c = UID.charAt(0);
if (c == 's'){
interfaceview.parttimejob();
}else if(c == 'l'){
interfaceview.administrators();
}
flag = false;
}else {
System.out.println("密码错误");
return ;
}
}
}
if (num == 0){
System.out.println("该编号不存在");
return ;
}
}
}
public String time(){
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyy年MM月dd日");
String s = sdf.format(d);
return s;
}
public void changepassword() throws IOException, ClassNotFoundException, InterruptedException { //修改密码方法
System.out.println("修改密码界面");
boolean flag = true;
while (flag){
System.out.println("请输入用户编号:");
String UID = TSUtility.readKeyBoard(10, false);
System.out.println("请输入名字:");
String username = TSUtility.readKeyBoard(5, false);
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = (ArrayList<User>) ois.readObject();
ois.close();
int num =0;
for(int i =0; i <array.size(); i++){
if(array.get(i).getUID().equals(UID)){
num =1;
if(array.get(i).getUsername().equals(username)){
System.out.println("请输入新密码:");
String password = TSUtility.readKeyBoard(10, false);
array.get(i).setPassword(password);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
oos.writeObject(array);
oos.close();
TSUtility.loadSpecialEffects();
System.out.println("密码修改成功");
flag = false;
}else {
System.out.println("姓名有误");
}
}
}
if (num == 0){
System.out.println("用户名有误");
}
}
}
}
Job_Applymethod类实现:
public class Job_Applymethod {
InformationMaintenancemethod informationmaintenancemethod = new InformationMaintenancemethod();
public void query_all_job() throws IOException, ClassNotFoundException {//查询所有职位信息方法
System.out.println("查询所有职位信息:");
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
for (Job job : arrjob){
System.out.println(job);
}
}
public ArrayList<Job> query_can_apply() throws IOException, ClassNotFoundException {//查询可申请职位信息方法
System.out.println("查询可申请职位信息:");
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\uid.txt"));
String str = br.readLine();
br.close();
ObjectInputStream ois1 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> users = (ArrayList<User>) ois1.readObject();
ois1.close();
String credit_rating = "";
for (User us : users){
if(us.getUID().equals(str)){
credit_rating = us.getCredit_rating();
break;
}
}
int i = Integer.parseInt(credit_rating);
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
int num = 0;
ArrayList<Job> arrjob3 = null;
for (Job job : arrjob){
num =0;
if(i >= Integer.parseInt(job.getJob_level())){// 用户等级>=工作等级
if(Integer.parseInt(job.getJob_content()) > 0){ //工作岗位需求人数>0
File file = new File("Level16\\src\\file\\职位申请.txt");
if(file.length() < 10){
num++;
System.out.println(job);
}else {
ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois2.readObject();
ois2.close();
for (ApplyJob app :arrapp){
if (app.getJID().equals(job.getJID())){
break;
}else {
num++;
}
if (num == arrapp.size()){ //有问题
System.out.println(job);
arrjob3 = new ArrayList<>();
arrjob3.add(job);
}
}
}
}
}
}
if(num == 0){
System.out.println("当前无可以申请的职位");
}
return arrjob3;
}
public void job_application() throws IOException, ClassNotFoundException { //职位申请方法
//添加职位时 没有用自已是否有时间工作判断
boolean flag = true;
while (flag){
System.out.println("欢迎来到职位申请界面");
System.out.println("可申请的职位有:");
query_can_apply();
System.out.println("您需要申请职位的营业执照编码是:");
String JID = TSUtility.readKeyBoard(18, false);
// int num = TSUtility.readInt();
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
int num = -1;
for(int i=0; i< arrjob.size(); i++){
if (arrjob.get(i).getJID().equals(JID)){
num = i;
}/*else {
System.out.println("你输入的编码不存在");
return;
}*/
}
if (num < 0 || num > arrjob.size() ){
System.out.println("你输入的编码有误");
continue;
}
File file = new File("Level16\\src\\file\\职位申请.txt");
if(file.length() <10){
ApplyJob app = date((num), arrjob);
ArrayList<ApplyJob> arrapp = new ArrayList<>();
arrapp.add(app);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\职位申请.txt"));
oos.writeObject(arrapp);
oos.close();
System.out.println("申请成功");
int i = Integer.parseInt(arrjob.get(num ).getJob_content()) -1; //将job所需人数-1
arrjob.get(num).setJob_content(String.valueOf(i));
ObjectOutputStream oos2 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos2.writeObject(arrjob); //将更改后的job集合序列化
oos2.close();
//将job集合信息更改
flag = false;
}else {
ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp1 = (ArrayList<ApplyJob>) ois2.readObject();
ois2.close();
for(ApplyJob app : arrapp1){
if(app.getJID().equals(arrjob.get(num).getJID())){
System.out.println("该职位已经添加过了");
continue;
}
}
ApplyJob app = date((num ), arrjob);
arrapp1.add(app);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\职位申请.txt"));
oos.writeObject(arrapp1);
System.out.println("申请成功");
oos.close();
int i = Integer.parseInt(arrjob.get(num ).getJob_content()) -1; //将job所需人数-1
arrjob.get(num).setJob_content(String.valueOf(i));
ObjectOutputStream oos2 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos2.writeObject(arrjob); //将更改后的job集合序列化
oos2.close();
flag = false;
}
}
}
public ApplyJob date(int num,ArrayList<Job> arrjob) throws IOException, ClassNotFoundException {//工作时间方法
boolean flag =true;
// ArrayList<ApplyJob> arrapp = null;
while (flag){
Calendar c = Calendar.getInstance();
int year1 = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH)+1;
int date1 = c.get(Calendar.DATE);
System.out.println("开始工作年月日为:");
System.out.println("年(如:2022):");
int year = TSUtility.readInt4();
if (year!=year1 ){
System.out.println("你输入的年有误");
continue;
}
System.out.println("月(如:01)");
int month = TSUtility.readInt();
if (month < month1 || month >12){
System.out.println("你输入的月有误");
continue;
}
System.out.println("日(如:01):");
int date = TSUtility.readInt();
if(month == month1){
if ( date > 31 || date <= date1){
System.out.println("你输入的日有误");
continue;
}
}else if(date < 1 || date > 31){
System.out.println("你输入的日有误");
continue;
}
String st1 = arrjob.get(num).getJob_section();
String[] st2 = st1.split("-");
if (month > Integer.parseInt(st2[1])){
System.out.println("不符合该工作时间要求");
continue;
}else if(month == Integer.parseInt(st2[1])){
if (date > Integer.parseInt(st2[2]) ){
System.out.println("不符合该工作时间要求");
continue;
}
}
System.out.println("开始时间为:");
System.out.println(year + "年" +month + "月" + date + "日");
int i = Integer.parseInt(arrjob.get(num).getJob_time());
c.set(year,month-1,date);
c.add(Calendar.DATE,i-1);
int year2 = c.get(Calendar.YEAR);
int month2 = c.get(Calendar.MONTH)+1;
int date2 = c.get(Calendar.DATE);
System.out.println("结束时间为:");
System.out.println(year2 + "年" +month2 + "月" + date2 + "日");
StringBuilder sb1 = new StringBuilder();
sb1.append(year).append("-").append(month).append("-").append(date);
String ks = sb1.toString();
StringBuilder sb2 = new StringBuilder();
sb2.append(year2).append("-").append(month2).append("-").append(date2);
String js = sb2.toString();
String jid = arrjob.get(num).getJID();
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\uid.txt"));
String id = br.readLine();
br.close();
ApplyJob applyJob = new ApplyJob(id,jid,ks,js);
return applyJob;
}
return null;
}
public void end_job() throws IOException, ClassNotFoundException, ParseException {//结束工作
System.out.println("欢迎来到结束工作界面");
boolean flag = true;
while (flag) {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois.readObject(); //拿到申请工作信息
ois.close();
// 注意职位申请列表中有已完成的工作 需要区分出来
int num1 =0;
for (ApplyJob app : arrapp) {
if (!app.getEnd()){
num1++;
System.out.print(app);
System.out.println(",当前状态为:"+app.getEnd());
}
}
if (num1 ==0){
System.out.println("你当前还没有工作中的兼职");
}
System.out.println("亲输入需要结束工作的营业执照编号:");
String JID = TSUtility.readKeyBoard(18, false);
int num =-1;
for (int i =0; i <arrapp.size(); i++){
if (arrapp.get(i).getJID().equals(JID)){
num = i;
break;
}
}
if (num == -1){
System.out.println("你输入的信息有误");
}
String st1 = arrapp.get(num).getWork_end();
// String[] st2 = st1.split("-");
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH) + 1;
int date = c.get(Calendar.DATE);
System.out.println("工作截止时间为:");
System.out.println(st1);
System.out.println("当前时间为:");
System.out.println(year + "-" + month + "-" + date );
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse(st1); //截止时间
Date dd = new Date();//当前时间
long l = d.getTime() - dd.getTime();
double time = Math.ceil(l * 1.0 / 1000 / 60 / 60 / 24);//>=0 表示没有逾期 <0 表示逾期
ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> arruser = (ArrayList<User>) ois2.readObject(); //拿到用户信息
ois2.close();
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\uid.txt"));
String st = br.readLine(); //拿到用户登入的Uid
int n = 0;
for (int i = 0; i < arruser.size(); i++) {
if (arruser.get(i).getUID().equals(st)) {
n = i;
}
}
ObjectInputStream ois3 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois3.readObject(); //拿到所有工作信息
ois3.close();
String n2 = ""; //兼职类型
for (int i = 0; i < arrjob.size(); i++) {
if (arrjob.get(i).getJID().equals(arrapp.get(num).getJID())) {
n2 = arrjob.get(i).getJobtype_name();
}
}
ObjectInputStream ois4 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\兼职类型.txt"));
ArrayList<JobType> arrjt = (ArrayList<JobType>) ois4.readObject(); //拿到所有兼职类型
ois4.close();
String salary = ""; //对应兼职类型的薪水
for (JobType jt : arrjt) {
if (jt.getJobtype_name().equals(n2)) {
salary = jt.getSalary();
}
}
int num2 = 0;
if (time >= 0) {
// System.out.println("你没有逾期");
File file = new File("Level16\\src\\file\\用户账户.txt");
if (file.length() < 10) {
UserAccount ua = new UserAccount(arrapp.get(num).getJID(), arruser.get(n).getCredit_rating(), salary);
ArrayList<UserAccount> arrua = new ArrayList<>();
arrua.add(ua);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
} else {
ObjectInputStream ois5 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arrua = (ArrayList<UserAccount>) ois5.readObject(); //拿到用户的账户
ois5.close();
int nu = 0;
for (int i =0 ; i <arrua.size(); i++){
if (arrua.get(i).getACID().equals(st)){
nu = i;
break;
}
}
String s = String.valueOf(Double.parseDouble(arrua.get(nu).getBalance()) + Double.parseDouble(salary));
arrua.get(nu).setBalance(s);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}
} else {
num2 = (int) Math.abs(time);
System.out.println("你已逾期" + num2 + "天");
File file = new File("Level16\\src\\file\\用户账户.txt");
double bl = informationmaintenancemethod.overdue_setting(); //返回的该信用等级对应的逾期金额比例
if (file.length() <= 10) {
double v = Double.parseDouble(salary) * bl *num2; //逾期num2天需要的扣除的费用
if (Double.parseDouble(salary) > v){
double salary2 = Double.parseDouble(salary)-v; //扣除逾期金额后剩余的金额
UserAccount ua = new UserAccount(arrapp.get(num).getJID(), arruser.get(n).getCredit_rating(), String.valueOf(salary2));
ArrayList<UserAccount> arrua = new ArrayList<>();
arrua.add(ua);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}else {
UserAccount ua = new UserAccount(arrapp.get(num).getJID(), arruser.get(n).getCredit_rating(), "0");
ArrayList<UserAccount> arrua = new ArrayList<>();
arrua.add(ua);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}
}else { //逾期且有账户
ObjectInputStream ois5 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arrua = (ArrayList<UserAccount>) ois5.readObject(); //拿到用户的账户
ois5.close();
int nu = 0;
for (int i =0 ; i <arrua.size(); i++){
if (arrua.get(i).getACID().equals(st)){
nu = i;
break;
}
}
double v = Double.parseDouble(salary) * bl *num2; //逾期num2天需要的扣除的费用
if (Double.parseDouble(salary) > v) {
double salary2 = Double.parseDouble(salary)-v; //扣除逾期金额后剩余的金额
String s = String.valueOf(Double.parseDouble(arrua.get(nu).getBalance()) + salary2);
arrua.get(nu).setBalance(s);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}else {
double salary2 = v -Double.parseDouble(salary);//扣除本次工作的金额后 还需要扣除的费用
if (Double.parseDouble(arrua.get(nu).getBalance()) >= salary2){
double v1 = Double.parseDouble(arrua.get(nu).getBalance()) - salary2; //扣除账户里的金额后 剩余的金额
arrua.get(nu).setBalance(String.valueOf(v1)); //将金额更改到集合
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}else {//账户余额不足 直接等于0
arrua.get(nu).setBalance("0");
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
}
}
}
}
arrapp.get(num).setEnd(true);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\职位申请.txt"));
oos.writeObject(arrapp);
oos.close();
System.out.println("工作结束成功");
break;
}
}
public void Completed_job() throws IOException, ClassNotFoundException {// 查询已完成的工作
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois.readObject();
ois.close();
int num =0;
for (ApplyJob app : arrapp){
if (app.getEnd()){
num++;
System.out.println(app);
}
}
if (num ==0){
System.out.println("你当前还没有已完成的工作");
}
}
public void to_be_completed() throws IOException, ClassNotFoundException {//查询正在兼职的信息
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois.readObject();
ois.close();
int num =0;
for (ApplyJob app : arrapp){
if (!app.getEnd()){
num ++;
System.out.println(app);
}
}
if (num ==0){
System.out.println("你当前没有正在进行的工作");
}
}
}
PartTimeJobmethod类实现:
public class PartTimeJobmethod {
Interfacemethod interfacemethod = new Interfacemethod();
public PartTimeJobmethod() throws InterruptedException, IOException, ClassNotFoundException {
}
public void modify() throws IOException, ClassNotFoundException { //修改个人信息
System.out.println("修改信息界面");
System.out.println("提示:不需要修改的信息回车即可");
System.out.println("请输入需要修改信息的用户编号:");
String UID = TSUtility.readKeyBoard(10, false);
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = (ArrayList<User>) ois.readObject();
ois.close();
int num =0;
for(int i =0; i <array.size(); i++){
if(array.get(i).getUID().equals(UID)){
num =1;
System.out.println("请输入新姓名:");
String username = TSUtility.readKeyBoard(5, true);
if(judge(username)){
username = array.get(i).getUsername();
}
System.out.println("请输入新年龄:");
String age = TSUtility.readKeyBoard(2, true);
if(judge(age)){
age = array.get(i).getAge();
}
System.out.println("请输入新性别:");
String sex = TSUtility.readKeyBoard(1, true);
if(judge(sex)){
sex = array.get(i).getSex();
}
System.out.println("请输入新手机号:");
String phone = TSUtility.readKeyBoard(20, true);
if(judge(phone)){
phone = array.get(i).getPhone();
}
System.out.println("请输入新院系");
String department = TSUtility.readKeyBoard(10, true);
if(judge(department)){
department = array.get(i).getDepartment();
}
User user = new User(array.get(i).getUID(),username,array.get(i).getPassword(),age,sex,
phone,department,array.get(i).getRegdat(),array.get(i).getCredit_rating(),array.get(i).getBalance());
array.set(i,user);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
oos.writeObject(array);
oos.close();
}
}
if(num == 0){
System.out.println("你输入的编号不存在");
return;
}
}
public boolean judge(String s){
if (s.length() == 0){
return true;
}else {
return false;
}
}
public void query_grade() throws InterruptedException, IOException, ClassNotFoundException {//信用等级查询
String UID = interfacemethod.UID();
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = (ArrayList<User>) ois.readObject();
ois.close();
for(User user: array){
if(user.getUID().equals(UID)) {
System.out.println("你当前的信用等级为:"+user.getCredit_rating()+"级");
}
}
}
public void query_balance() throws InterruptedException, IOException, ClassNotFoundException { //余额查询
String UID = interfacemethod.UID();
File file = new File("Level16\\src\\file\\用户账户.txt");
if (file.length() < 10){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> array = (ArrayList<User>) ois.readObject();
ois.close();
for(User user: array){
if(user.getUID().equals(UID)) {
System.out.println("你当前的余额为:"+user.getBalance());
}
}
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arruser = (ArrayList<UserAccount>) ois.readObject();
ois.close();
System.out.println(arruser.get(0).getBalance());
}
}
}
SystemManagementmethod类实现:
public class SystemManagementmethod {
Interfacemethod interfacemethod = new Interfacemethod();
public SystemManagementmethod() throws InterruptedException, IOException, ClassNotFoundException {
}
public void delete_account() throws IOException, ClassNotFoundException { //删除账户
boolean flag = true;
while (flag){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arrua = (ArrayList<UserAccount>) ois.readObject();
ois.close();
if (arrua.size() == 0){
System.out.println("还未有账户,请前创建");
break;
}
for (UserAccount ua : arrua){
System.out.println(ua);
}
System.out.println("你需要删除第几条信息");
int num = TSUtility.readInt()-1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
arrua.remove(num);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
System.out.println("删除成功");
flag =false;
}
}
public void delete_user() throws IOException, ClassNotFoundException {//删除用户
boolean flag = true;
while (flag){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> arruser = (ArrayList<User>) ois.readObject();
ois.close();
if (arruser.size() == 0){
System.out.println("还未有用户,请前添加");
break;
}
for (User us : arruser){
System.out.println(us);
}
System.out.println("你需要删除第几条信息");
int num = TSUtility.readInt()-1;
if (num < 0){
System.out.println("你输入的信息有误");
continue;
}
arruser.remove(num);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\user.txt"));
oos.writeObject(arruser);
oos.close();
System.out.println("删除成功");
flag =false;
}
}
public void delete_work() throws IOException, ClassNotFoundException {//删除兼职信息
while (true){
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
if (arrjob.size() == 0){
System.out.println("还没有兼职信息");
break;
}
for (Job j : arrjob){
System.out.println(j);
}
System.out.println("你需要删除第几条信息哪");
int num = TSUtility.readInt()-1;
if (num < 0 || num > arrjob.size()){
System.out.println("你输入的信息有误");
continue;
}
ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois2.readObject();
ois2.close();
for (int i =0; i <arrapp.size(); i++){
if (arrapp.get(i).getJID().equals(arrjob.get(num).getJID())){
if (!arrapp.get(i).getEnd()){
System.out.println("该工作正在进行中,确定要删除吗(Y/N)");
char c = TSUtility.readConfirmSelection();
if(c =='Y'){
arrjob.remove(num);
arrapp.remove(i);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
ObjectOutputStream oos2 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\职位申请.txt"));
oos2.writeObject(arrapp);
oos2.close();
System.out.println("删除成功");
return;
}else {
System.out.println("未删除");
return;
}
}else {
arrjob.remove(num);
arrapp.remove(i);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
ObjectOutputStream oos2 = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\职位申请.txt"));
oos2.writeObject(arrapp);
oos2.close();
System.out.println("删除成功");
return;
}
}
}
arrjob.remove(num);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\job.txt"));
oos.writeObject(arrjob);
oos.close();
System.out.println("删除成功");
break;
}
}
public void add_information() throws IOException {//添加学生信息
while (true){
System.out.println("请输入添加学生或管理员姓名:");
String name = TSUtility.readKeyBoard(4, false);
System.out.println("请输入编号:");
String UID = TSUtility.readKeyBoard(10, false);
if ( (UID.charAt(0) != 's' && UID.charAt(0) != 'l') || UID.length() != 10){
System.out.println("你输入的信息有误");
continue;
}
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\systemuser.txt"));
Properties prop =new Properties();
prop.load(br);
br.close();
Set<String> names = prop.stringPropertyNames();
for (String key : names){
if (key.equals(UID)){
System.out.println("该用于已经信息存在");
return;
}
}
prop.put(UID,name);
BufferedWriter bw = new BufferedWriter(new FileWriter("Level16\\src\\file\\systemuser.txt"));
prop.store(bw,null);
bw.close();
System.out.println("添加成功");
break;
}
}
public void add_user() throws InterruptedException, IOException, ClassNotFoundException { //添加用户
interfacemethod.register();
}
public void add_account() throws IOException, ClassNotFoundException {//添加账户
while (true){
File file = new File("Level16\\src\\file\\用户账户.txt");
if (file.length() <10){
System.out.println("请输入账号编号(与用户编号相同):");
String UID = TSUtility.readKeyBoard(10, false);
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\systemuser.txt"));
Properties prop =new Properties();
prop.load(br);
br.close();
Set<String> names = prop.stringPropertyNames();
int num =0;
for (String key : names){
if (key.equals(UID)){
num++;
break;
}
}
if (num == 0){
System.out.println("该账号编号不正确");
continue;
}
System.out.println("请输入信用等级(0-5)");
int credit_rating = TSUtility.readInt1();
if (credit_rating <0 || credit_rating >5){
System.out.println("输入信息有误");
continue;
}
System.out.println("请输入余额:");
String balance = TSUtility.readKeyBoard(5, false);
if (Integer.parseInt(balance) < 0){
System.out.println("输入的信息有误");
continue;
}
UserAccount ua = new UserAccount(UID,String.valueOf(credit_rating),balance);
ArrayList<UserAccount> arrus = new ArrayList<>();
arrus.add(ua);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrus);
oos.close();
System.out.println("创建成功");
break;
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arrua = (ArrayList<UserAccount>) ois.readObject();
ois.close();
System.out.println("请输入账号编号(与用户编号相同):");
String UID = TSUtility.readKeyBoard(10, false);
BufferedReader br = new BufferedReader(new FileReader("Level16\\src\\file\\systemuser.txt"));
Properties prop =new Properties();
prop.load(br);
br.close();
for (UserAccount ua: arrua){
if (ua.getACID().equals(UID)){
System.out.println("该账号已存在");
return;
}
}
Set<String> names = prop.stringPropertyNames();
int num =0;
for (String key : names){
if (key.equals(UID)){
num++;
break;
}
}
if (num == 0){
System.out.println("该账号编号不正确");
continue;
}
System.out.println("请输入信用等级(0-5)");
int credit_rating = TSUtility.readInt1();
if (credit_rating <0 || credit_rating >5){
System.out.println("输入信息有误");
continue;
}
System.out.println("请输入余额:");
String balance = TSUtility.readKeyBoard(5, false);
if (Integer.parseInt(balance) < 0){
System.out.println("输入的信息有误");
continue;
}
UserAccount ua = new UserAccount(UID,String.valueOf(credit_rating),balance);
arrua.add(ua);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Level16\\src\\file\\用户账户.txt"));
oos.writeObject(arrua);
oos.close();
System.out.println("创建成功");
break;
}
}
}
public void query_user() throws IOException, ClassNotFoundException {//查询用户
File file = new File("Level16\\src\\file\\user.txt");
if (file.length() <10){
System.out.println("请先添加在查询");
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\user.txt"));
ArrayList<User> arruser = (ArrayList<User>) ois.readObject();
ois.close();
for (User u : arruser){
System.out.println(u);
}
}
}
public void query_account() throws IOException, ClassNotFoundException {//查询账户
File file = new File("Level16\\src\\file\\用户账户.txt");
if (file.length() <10){
System.out.println("请先添加在查询");
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\用户账户.txt"));
ArrayList<UserAccount> arrua = (ArrayList<UserAccount>) ois.readObject();
ois.close();
for (UserAccount ua : arrua){
System.out.println(ua);
}
}
}
public void positions_placed() throws IOException, ClassNotFoundException {// 查询已投放职位
File file = new File("Level16\\src\\file\\job.txt");
if (file.length() <10){
System.out.println("请先添加在查询");
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\job.txt"));
ArrayList<Job> arrjob = (ArrayList<Job>) ois.readObject();
ois.close();
for (Job job : arrjob){
System.out.println(job);
}
}
}
public void completed_position() throws IOException, ClassNotFoundException {//查询已完成职位
File file = new File("Level16\\src\\file\\职位申请.txt");
if (file.length() <10){
System.out.println("请先添加在查询");
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois.readObject();
ois.close();
for (ApplyJob app : arrapp){
if (app.getEnd()){
System.out.println(app);
}
}
}
}
public void overdue_information() throws IOException, ClassNotFoundException, ParseException {//查询逾期兼职信息
File file = new File("Level16\\src\\file\\职位申请.txt");
if (file.length() <10){
System.out.println("请先添加在查询");
}else {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("Level16\\src\\file\\职位申请.txt"));
ArrayList<ApplyJob> arrapp = (ArrayList<ApplyJob>) ois.readObject();
ois.close();
int num = 0;
for (ApplyJob app : arrapp){
if (!app.getEnd()){
String st1 = app.getWork_end(); //获取截止时间
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH) + 1;
int date = c.get(Calendar.DATE);
/*System.out.println("工作截止时间为:");
System.out.println(st1);
System.out.println("当前时间为:");
System.out.println(year + "-" + month + "-" + date + "-");*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse(st1); //截止时间
Date dd = new Date();//当前时间
long l = d.getTime() - dd.getTime();
double time = Math.ceil(l * 1.0 / 1000 / 60 / 60 / 24);//>=0 表示没有逾期 <0 表示逾期
if (time < 0){
num ++;
System.out.println(app);
}
}
}
if (num ==0){
System.out.println("没有兼职逾期");
}
}
}
以上便是该系统的简单实现