JavaSE项目二:校园兼职平台

项目前提】

  1. 掌握java基本语法
  2. 熟悉使用流程控制
  3. 理解面向对象思想
  4. 熟练封装,继承,多态
  5. 熟悉使用接口,异常
  6. 熟悉使用集合
  7. 熟悉掌握I/o流相关操作
  8. 可使用自己学习的拓展知识对项目进行扩充

项目说明

  1. 据了解,目前在校大学生80%以上有做兼职的需求,兼职打工已经不仅仅是经济困难的学生赚取生活费用的途径。调查显示,全球经济危机对就业产生冲击,用人单位对人员的社会实践能力要求提高,大学期间必要的社会实践既可以提高能力,又为适应社会,减轻家庭经济负担起到了积极的作用;社会中虚假兼职机构、欺骗性中介机构充斥,真伪难辨,学生受骗事件频发,极大的损害了学生的经济利益,甚至对学生的人生安全造成威胁。从校园踏入社会,兼职只是一段小小的插曲,通过兼职丰富阅历、增长社会经验固然是好事,可是毫无戒备的步入社会,不仅会事与愿违,还可能造成不必要的损所以。所以,我们需求设计一个校园兼职平台来方便在校学生找兼职。
  2. 本平台根据角色定位不同有不同的模块,首先系统有一个登录注册模块,属于兼职人员的模块有个人信息管理和兼职申请;属于管理员的模块有基本信息维护、兼职信息投放和系统管理。
  3. 平台登录注册:用户可以通过账号密码登录平台,如果用户是第一次使用该平台,则可以通过注册方式完成信息录入。平台根据用户输入的账号密码,判断该用户的角色是兼职人员还是管理员,展示不同的操作界面。如果用户忘记密码,可以通过自己的账号和注册时录入的真实姓名找回密码。
  4. 个人信息管理:能够对用户的基本信息进行管理,包括个人信息的修改,如学生转到别的专业,此时要修改学生的基本信息;修改密码,为了账户的安全性,可以修改用户的密码。查询信用等级,比如有一个用户一开始可以完成兼职等级最高的工作,但是在这次工作中,未能按时完成工作,于是管理员降低了该用户的信用等级,该用户就不能接高级的兼职工作了。查询余额,用户每次按时完成兼职能得到一笔费用,有逾期会扣除一部分佣金,最后得到总的余额。
  5. 兼职申请模块:用户能够查询所有的职位信息,因为信用等级的限制,用户也可以只查询自己能够申请的职位信息。查询到合适的职位用户可以直接申请,申请后到达工作截至时间前完成工作可以提前结束工作得到佣金,如果逾期后完成,管理员会调整用户的信用等级。用户可以查询自己已经完成过的兼职信息和自己正在完成的兼职信息。
  6. 基本信息维护模块:管理员能够根据用户完成兼职的情况动态的调整用户的兼职等级状态。管理员可以调整兼职的等级,供用户选择。管理员能够根据兼职的等级不同设置逾期费用扣除比例,比如最高级的兼职逾期一天扣10元,扣除兼职费用后继续扣除用户余额,直到用户余额为0,自动结束工作,结算费用。
  7. 兼职信息投放:管理员可以把所有公司的兼职招聘信息发布到网上,根据公司的需求设置岗位所需人员,工资以及兼职的时间段,比如发传单,这份兼职需要周一到周五的上午9点至11点工作,那么在这个时间段已经有了其他工作的用户就不能申请该工作。
  8. 系统管理模块:管理员能够删除管理员账户,也能删除平台用户以及一些完成过的兼职信息。管理员能够添加平台用户信息到系统,本平台是针对学生的软件,所以能够注册的只能是学生,所以平台需要提前将学生信息录入系统,用户才能注册账号,如果未能及时录入信息照成无法注册,那么就需要联系管理员进行信息录入。管理员可以添加其他的管理员账户,为了安全起见,管理员和普通用户一样能够修改密码。管理员还能够查询所有的用户信息、管理员账户信息、已经投放的职位信息、已经完成的兼职信息和已经逾期的兼职信息。

项目内容】

项目功能结构图:

项目功能如下:

(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流直接存在文件,可也直接在文件里读的数据)

下面是参考实现的部分代码

包结构图:

view层

IndexView

package com.guanqia16.view;

import com.guanqia16.Util.TSUtility;

import java.io.IOException;
import java.text.ParseException;

public class IndexView {
    LoginView loginVi = new LoginView();

    public IndexView() {
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException, ParseException {
        IndexView i = new IndexView();
        i.menu();
    }

    public void menu() throws IOException, ClassNotFoundException, ParseException {
        char key = 0;
        while (true) {
            System.out.println("    欢迎来到校园兼职平台     ");
            System.out.println("1.登录");
            System.out.println("2.注册");
            System.out.println("3.忘记密码");
            System.out.println("4.退出");
            System.out.println("请输入(1-4):");
            key = TSUtility.readMenuSelectionPro();
            switch (key) {
                case '1':
                    loginVi.login();
                    break;
                case '2':
                    loginVi.register();
                    break;
                case '3':
                    loginVi.retrievePassword();
                    break;
                case '4':
                    System.out.println("确认退出吗?(y/n):");
                    char c = TSUtility.readConfirmSelection();
                    if (c=='y'){
                        System.exit(0);
                    }
                    break;
            }
        }
    }
}

LoginView

package com.guanqia16.view;

import com.guanqia12.view.TSUtility;
import com.guanqia16.Util.Tool;
import com.guanqia16.domain.User;

import java.io.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Properties;

public class LoginView {
    ArrayList<User> array = new ArrayList<>();
    public static String userFile = "idea_test\\src\\com\\guanqia16\\File\\user.txt";                     //已注册用户列表
    public static String idAndUserNameFile = "idea_test\\src\\com\\guanqia16\\File\\idAndUsername.txt";   //可注册的所有人的UID和姓名
    StudentView stu = new StudentView();
    ManageView man = new ManageView();

    //注册
    public void register() throws IOException, ClassNotFoundException, ParseException {
        System.out.println("***   <注册界面>   ***");
        System.out.println("请输入用户编号:");
        String UID = TSUtility.readKeyBoard(4, false);
        boolean flag = false;
        //userList已注册用户集合
        ArrayList<User> userList = Tool.uSerStu(userFile);
        if (userList != null) {
            for (User user : userList) {
                if (!(Integer.parseInt(UID) == user.getUID())) {
                    continue;
                } else {
                    flag = true;
                }
            }
        }
        if (flag) {
            System.out.println("该账户已存在!");
        } else {
            //所有可注册用户集合
            ArrayList<User> allUserList = Tool.uSerStu(idAndUserNameFile);
            for (User user : allUserList) {
                if (!(UID.equals(String.valueOf(user.getUID())))) {
                    continue;
                } else {
                    flag = true;
                    break;
                }
            }
            while (!flag) {
                System.out.println("查无此人,请检查输入编号是否正确!重新输入:");
                UID = TSUtility.readKeyBoard(4, false);
                for (User allUser : allUserList) {
                    if (!(UID.equals(String.valueOf(allUser.getUID())))) {
                        continue;
                    } else {
                        flag = true;
                        break;
                    }
                }
            }
            System.out.println("请输入用户密码:");
            String password = TSUtility.readKeyBoard(10, false);
            System.out.println("请输入姓名:");
            String username = TSUtility.readKeyBoard(7, false);
            boolean f = true;
            while (f) {
                for (User allUser : allUserList) {
                    if (!(UID.equals(String.valueOf(allUser.getUID())))) {
                        continue;
                    } else {
                        if (!(username.equals(allUser.getUsername()))) {
                            System.out.println("您输入的姓名有误!请重新输入");
                            username = TSUtility.readKeyBoard(5, false);
                            break;
                        } else {
                            f = false;
                        }
                    }
                }
            }
            System.out.println("请输入性别:");
            String sex = TSUtility.readKeyBoard(1, false);
            System.out.println("请输入您的年龄:");
            String age = TSUtility.readKeyBoard(3, false);
            System.out.println("请输入电话:");
            String phone = TSUtility.readKeyBoard(11, false);
            System.out.println("请输入所在院系:");
            String department = TSUtility.readKeyBoard(6, false);
            System.out.println("请输入注册日期:");
            String regdat = TSUtility.readKeyBoard(20, false);
            User user = new User(Integer.parseInt(UID), password, username, Integer.parseInt(age), sex, phone, department, regdat);
            userList.add(user);
            Tool.uSerStu2(userList, userFile);
            System.out.println("注册成功,请登录");
            login();
        }

    }


    //登录
    public void login() throws IOException, ClassNotFoundException, ParseException {
        int count = 5;
        boolean flag = true;
        boolean flag1 = true;
        while (flag) {
            ArrayList<User> userList = Tool.uSerStu(userFile);
            if (userList.size() == 0) {
                System.out.println("无注册人员,请先注册");
                register();
            } else {
                System.out.println("***   <登录界面>   ***");
                System.out.println("请输入你的登录UID:");
                String UID = TSUtility.readKeyBoard(4, false);
                System.out.println("请输入你的登录密码:");
                String password = TSUtility.readKeyBoard(8, false);
                for (User user : userList) {
                    if (Integer.parseInt(UID) == user.getUID() && password.equals(user.getPassword())) {
                        System.out.println("登陆成功");
                        if (UID.startsWith("1")) {
                            stu.menu(UID, password);
                            flag=false;
                        } else if (UID.startsWith("2")) {
                            man.menu(UID, password);
                            flag=false;
                        }
                        flag1 = true;
                        flag = false;
                        break;
                    } else {
                        flag1 = false;
                    }
                }
                if (!flag1) {
                    if (count <= 0) {
                        System.out.println("登录次数不足,请联系管理!");
                        return;
                    } else {
                        count--;
                        System.out.println("登录失败,账户和密码不匹配!");
                        System.out.println("您还有" + count + "次登录机会,请重新输入");
                        System.out.println("是否继续登录:(y/n)");
                        char c = TSUtility.readConfirmSelection();
                        if (c=='N'){
                            flag=false;
                        }
                    }
                }
            }
        }
    }


    //找回密码
    public void retrievePassword() throws IOException, ClassNotFoundException {
        ArrayList<User> stuList = Tool.uSerStu(userFile);
        String psw = null;
        System.out.println("请输入您的UID:");
        String UID = TSUtility.readKeyBoard(4, false);
        System.out.println("请输入您的姓名:");
        String username = TSUtility.readKeyBoard(4, false);
        for (User user : stuList) {
            if (String.valueOf(user.getUID()).equals(UID) && user.getUsername().equals(username)) {
                psw = user.getPassword();
            }
        }
        if (psw == null) {
            System.out.println("该用户不存在");
        } else {
            System.out.println("您的密码是:" + psw);
        }
    }

    //个人信息修改
    //可以修改个人注册时录入的信息,学号和注册时间不可更改,
    public void modifyInfo(String UID) throws IOException, ClassNotFoundException {
        System.out.println("    个人信息修改界面    ");
        System.out.println("UID:" + UID);
        array = uSer(userFile);
        for (int i = 0; i < array.size(); i++) {
            User user = array.get(i);
            if (UID.equals(String.valueOf(user.getUID()))) {
                int index = i;
                String uid = String.valueOf(user.getUID());
                String pwd = String.valueOf(user.getPassword());
                System.out.println("请输入修改后的姓名:");
                String username = TSUtility.readKeyBoard(4, false);
                System.out.println("请输入修改后的性别:");
                String sex = TSUtility.readKeyBoard(1, false);
                System.out.println("请输入新的的年龄:");
                String age = TSUtility.readKeyBoard(3, false);
                System.out.println("请输入新的电话:");
                String phone = TSUtility.readKeyBoard(11, false);
                System.out.println("请输入修改后的院系:");
                String department = TSUtility.readKeyBoard(6, false);
                String regdat = user.getRegdat();
                User u = new User(Integer.parseInt(uid), pwd, username, Integer.parseInt(age), sex, phone, department, regdat);
                array.set(index, u);
                ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(userFile));
                oos.writeObject(array);
                oos.close();
                System.out.println("修改成功");
                break;
            }
        }
    }

    //修改密码
    public void modifyPwd(String UID, String password) throws IOException, ClassNotFoundException, ParseException {
        array = uSer(userFile);
        System.out.println("您的UID为:" + UID);
        System.out.println("您的原密码为:" + password);
        for (int i = 0; i < array.size(); i++) {
            User user = array.get(i);
            if (UID.equals(String.valueOf(user.getUID()))) {
                System.out.println("请输入新的密码:");
                String pwd = TSUtility.readKeyBoard(8, false);
                user.setPassword(pwd);
                array.add(i, user);
                break;
            }
        }
        Tool.uSerStu2(array, userFile);
        System.out.println("修改成功!");
        login();
    }

    //查询信用等级
    //也可以查询个人的信用等级,若信用等级不是最高,则查询个人信用等级时附加显示“按时完成X次后信用等级恢复至X级”
    // (默认未逾期完成兼职工作3次恢复1级信用等级,等级梯度为1-5级,5级最高)。
    public void lookCreditRating(String UID) throws IOException, ClassNotFoundException {
        array = uSer(userFile);
        for (int i = 0; i < array.size(); i++) {
            User user = array.get(i);
            if (UID.equals(String.valueOf(user.getUID()))) {
                int credit_rating = user.getCredit_rating();
                if (credit_rating < 5) {
                    int count = user.getCount();
                    System.out.println("您的信誉等级为:"+credit_rating+"按时完成" + count + "次后信用等级恢复至" + (credit_rating + 1) + "级");
                } else if (credit_rating == 5) {
                    System.out.println("您的信用等级为:" + credit_rating + "请继续保持!");
                }
                break;
            }
        }
    }

    //查询用户余额
    public void lookBalance(String UID) throws IOException, ClassNotFoundException {
        array = uSer(userFile);
        for (int i = 0; i < array.size(); i++) {
            User user = array.get(i);
            if (UID.equals(String.valueOf(user.getUID()))) {
                double balance = user.getBalance();
                System.out.println("您的余额为:" + balance);
                break;
            }
        }
    }

    //获取用户列表集合
    public ArrayList<User> uSer(String file) throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
        Object obj = ois.readObject();
        ArrayList<User> set = (ArrayList<User>) obj;
        return set;
    }

    private static void myStore(Properties prop, String file) throws IOException {
        FileWriter fw = new FileWriter(file);
        prop.store(fw, null);
        fw.close();
    }

    private static void myLoad(Properties prop, String file) throws IOException {
        FileReader fr = new FileReader(file);
        prop.load(fr);
        fr.close();
    }


}

ManageView

package com.guanqia16.view;

import com.guanqia16.Util.TSUtility;
import com.guanqia16.service.ManageService;

import java.io.IOException;
import java.text.ParseException;

//教师登录主界面
public class ManageView {
    public void menu(String UID, String password) throws IOException, ClassNotFoundException, ParseException {
        ManageService manageService = new ManageService();
        //包括兼职人员设置、兼职的金额设置、兼职的时间录入以及兼职的其他信息录入
        boolean flag = true;
        while (flag) {
            System.out.println("------------欢迎进入校园兼职平台管理系统-------------");
            System.out.println("1.基本信息维护   2.兼职信息投放   3.系统管理   4.退出");
            char n = TSUtility.readMenuSelection();
            switch (n) {
                case '1':
                    boolean flag1 = true;
                    while (flag1) {
                        System.out.println("********************基本信息维护*************************");
                        System.out.println("1.兼职设置   2.用户信用调整   3.逾期费用扣除比例调整   4.退出");
                        char n1 = TSUtility.readMenuSelection();
                        switch (n1) {
                            case '1':
                                boolean flag11 = true;
                                while (flag11) {
                                    System.out.println("################兼职设置###############");
                                    System.out.println("1.兼职等级设置    2.兼职类型设置   3.退出");
                                    char c = TSUtility.readMenuSelectionMin();
                                    switch (c) {
                                        case '1':
                                            manageService.setJobLevel();
                                            break;
                                        case '2':
                                            boolean flag12 = true;
                                            while (flag12) {
                                                System.out.println("###############兼职类型设置##############");
                                                System.out.println("1.增加兼职类型    2.删除兼职类型    3.退出");
                                                char c1 = TSUtility.readMenuSelectionMin();
                                                switch (c1) {
                                                    case '1':
                                                        manageService.addJobType();
                                                        break;
                                                    case '2':
                                                        manageService.deleteJobType();
                                                        break;
                                                    case '3':
                                                        flag12 = false;
                                                        break;
                                                }
                                            }
                                            break;
                                        case '3':
                                            flag11 = false;
                                            break;
                                    }
                                }
                                break;
                            case '2':
                                manageService.setStuCredit();
                                break;
                            case '3':
                                manageService.setDeductSalary();
                                break;
                            case '4':
                                flag1 = false;
                                break;
                        }
                    }
                    break;
                case '2':
                    boolean flag2 = true;
                    while (flag2) {
                        System.out.println("***********************兼职信息投放******************************");
                        System.out.println("请输入你需要的功能:1-兼职信息录入   2-兼职信息修改   3-退出");
                        char n2 = TSUtility.readMenuSelectionMin();
                        switch (n2) {
                            case '1':
                                System.out.println("==========================兼职信息录入=================================");
                                manageService.releaseInfo();
                                break;
                            case '2':
                                System.out.println("==========================兼职信息修改=================================");
                                try {
                                    manageService.setJobInfo();
                                } catch (Exception e) {
                                    System.out.println("失败原因:" + e.getMessage());
                                }
                                break;
                            case '3':
                                System.out.println("确认退出吗?(Y/N):");
                                char c = TSUtility.readConfirmSelection();
                                if (c == 'Y') {
                                    flag2 = false;
                                }
                                break;
                        }
                    }
                    break;
                case '3':
                    boolean flag3 = true;
                    while (flag3) {
                        System.out.println("****************系统管理***********************");
                        System.out.println("1.添加   2.删除   3.账户密码修改   4.查询   5.退出");
                        char n3 = TSUtility.readMenuSelectionPro();
                        switch (n3) {
                            case '1':
                                manageService.addIdAndUserName();
                                break;
                            case '2':
                                boolean flag02 = true;
                                while (flag02) {
                                    System.out.println("===================删除页面===================");
                                    System.out.println("1-删除管理员   2-删除用户   3-删除兼职信息   4-退出");
                                    char n02 = TSUtility.readMenuSelection();
                                    switch (n02) {
                                        case '1':
                                            manageService.deleteMan(UID);
                                            break;
                                        case '2':
                                            manageService.deleteStu();
                                            break;
                                        case '3':
                                            manageService.deleteJobInfo();
                                            break;
                                        case '4':
                                            flag02 = false;
                                            break;
                                    }
                                }
                                break;
                            case '3':
                                manageService.modifyPassword(UID);
                                break;
                            case '4':
                                boolean flag03 = true;
                                while (flag03) {
                                    System.out.println("===================查询页面===================");
                                    System.out.println("1-用户账户   2-管理员账户   3-已投放兼职   4-已完成兼职  5-逾期兼职  6-退出");
                                    char n03 = TSUtility.readMenuSelectionProPro();
                                    switch (n03) {
                                        case '1':
                                            manageService.selectUser();
                                            break;
                                        case '2':
                                            manageService.selectAdministrator();
                                            break;
                                        case '3':
                                            manageService.selectAllJob();
                                            break;
                                        case '4':
                                            manageService.selectCompleteJob();
                                            break;
                                        case '5':
                                            manageService.selectOverdueJob();
                                            break;
                                        case '6':
                                            flag03 = false;
                                            break;
                                    }
                                }
                                break;
                            case '5':
                                flag3 = false;
                                break;
                        }
                    }
                    break;
                case '4':
                    System.out.println("确认退出吗?(y/n):");
                    char c = TSUtility.readConfirmSelection();
                    if (c == 'Y') {
                        flag = false;
                    }
                    break;
            }
        }
    }


}

StudentView

package com.guanqia16.view;

import com.guanqia16.Util.TSUtility;
import com.guanqia16.service.StudentService;

import java.io.IOException;
import java.text.ParseException;

//学生登录主界面
public class StudentView {


    public void menu(String UID, String password) throws IOException, ClassNotFoundException, ParseException {
        boolean flag = true;
        while (flag) {
            System.out.println("------------学生界面------------");
            System.out.println("1.个人信息管理 2.兼职申请 3.退出登录");
            char key = TSUtility.readMenuSelectionPro();
            switch (key) {
                case '1':
                    boolean flag1 = true;
                    LoginView loginView = new LoginView();
                    while (flag1) {
                        System.out.println("*******************个人信息管理界面********************");
                        System.out.println("1.个人信息修改 2.密码修改 3.查询信用等级 4.查询余额功能 5.退出");
                        System.out.println("请选择您的操作(1-5):");
                        char c = TSUtility.readMenuSelectionPro();
                        switch (c) {
                            case '1':
                                loginView.modifyInfo(UID);
                                break;
                            case '2':
                                loginView.modifyPwd(UID, password);
                                break;
                            case '3':
                                loginView.lookCreditRating(UID);
                                break;
                            case '4':
                                loginView.lookBalance(UID);
                                break;
                            case '5':
                                flag1 = false;
                                break;
                        }
                    }
                    break;
                case '2':
                    StudentService studentService = new StudentService();
                    //包括兼职信息查询、申请工作和结束工作。
                    boolean flag2 = true;
                    while (flag2) {
                        System.out.println("***************兼职申请界面*****************");
                        System.out.println("1.兼职信息查询   2.申请工作  3.结束工作  4.退出");
                        System.out.println("请选择您的操作(1-4):");
                        char c1 = TSUtility.readMenuSelectionPro();
                        switch (c1) {
                            case '1':
                                //可以查询所有的兼职信息,包括自己能申请的职位和不能申请的职位,也可以只查看自己能申请的职位
                                // (是否可申请与信用等级、岗位所需人员、兼职时间相关)。
                                // 用户还可查看自己已完成的兼职信息和自己正在完成的兼职信息。
                                boolean flag21 = true;
                                while (flag21) {
                                    System.out.println("********************兼职信息查询********************");
                                    System.out.println("1.查询所有兼职 2.可申请兼职 3.已完成兼职 4.正在兼职 5.退出");
                                    System.out.println("请选择您的操作(1-5):");
                                    char c = TSUtility.readMenuSelectionPro();
                                    switch (c) {
                                        case '1':
                                            //查询所有兼职
                                            studentService.applyAllWork();
                                            break;
                                        case '2':
                                            //可申请兼职
                                            studentService.mayApplyJob(UID);
                                            break;
                                        case '3':
                                            studentService.completeJob(UID);
                                            break;
                                        case '4':
                                            studentService.doingJob(UID);
                                            break;
                                        case '5':
                                            flag21=false;
                                            break;

                                    }
                                }
                                break;
                            case '2':
                                studentService.ApplyJob(UID, password);
                                break;
                            case '3':
                                studentService.FinishWord(UID);
                                break;
                            case '4':
                                flag2 = false;
                                break;
                        }
                    }
                    break;
                case '3':
                    System.out.println("确认退出吗?(y/n):");
                    char c = TSUtility.readConfirmSelection();
                    if (c == 'Y') {
                        flag = false;
                    }
            }
        }
    }
}

service层

ManageView

package com.guanqia16.service;

import com.guanqia16.Util.TSUtility;
import com.guanqia16.Util.Tool;
import com.guanqia16.domain.ApplyJob;
import com.guanqia16.domain.Job;
import com.guanqia16.domain.User;
import com.guanqia16.view.LoginView;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Set;

public class ManageService {

    public static String JobList = "idea_test\\src\\com\\guanqia16\\File\\jobList.txt"; //兼职信息文件
    public static String JobType = "idea_test\\src\\com\\guanqia16\\File\\jobType.txt";  //兼职类型
    int count = 1;
    LoginView l=new LoginView();

    //兼职等级设置
    public void setJobLevel() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        boolean flag = false;
        if (jobList.size() != 0) {
            for (Job job : jobList) {
                System.out.println(job);
            }
            System.out.println("请输入需要修改的营业执照编号:");
            String JID = TSUtility.readKeyBoard(4, false);
            for (Job job : jobList) {
                if (Integer.parseInt(JID) == job.getJID()) {
                    System.out.println("当前兼职等级为:" + job.getJob_level());
                    System.out.println("请输入修改后的兼职等级(1-5):");
                    String jobLevel = TSUtility.readKeyBoard(1, false);
                    job.setJob_level(Integer.parseInt(jobLevel));
                    Tool.serJob(jobList);
                    System.out.println("修改成功!");
                    flag = true;
                }
            }
        }
        if (jobList.size() == 0) {
            System.out.println("暂无兼职信息,请先添加!");
            return;
        } else if (!flag) {
            System.out.println("修改失败!");
        }
    }

    //增加兼职类型
    public void addJobType() throws IOException {
        int count = 1;
        Properties prop = new Properties();
        Tool.myLoad(prop, JobType);
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            Object value = prop.get(key);
            System.out.println(key + ":" + value);
            if (count < Integer.parseInt(String.valueOf(key))) {
                count = Integer.parseInt(String.valueOf(key));
            }
        }
        count++;
        System.out.println("请输入您要添加的兼职类型:");
        String jobTypeName = TSUtility.readKeyBoard(5, false);
        prop.put(String.valueOf(count), jobTypeName);
        Tool.myStore(prop, JobType);
        System.out.println("添加成功!");
    }

    //删除兼职类型
    public void deleteJobType() throws IOException {
        Properties prop = new Properties();
        Tool.myLoad(prop, JobType);
        boolean flag = true;
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            Object value = prop.get(key);
            System.out.println(key + ":" + value);
        }
        System.out.println("请输入需要删除的兼职类型编号:");
        String JTID = TSUtility.readKeyBoard(2, false);
        String key1 = "";
        String value1 = "";
        for (Object key : keys) {
            Object value = prop.get(key);
            if (String.valueOf(key).equals(JTID)) {
                key1 = JTID;
                value1 = String.valueOf(value);
                flag = true;
                break;
            } else {
                flag = false;
            }
        }
        if (flag) {
            prop.remove(key1, value1);
            Properties prop1 = new Properties();
            for (Object key : keys) {
                Object value = prop.get(key);
                prop1.put(String.valueOf(count), String.valueOf(value));
                count++;
            }
            Tool.myStore(prop1, JobType);
            System.out.println("删除成功!");
            return;
        } else {
            System.out.println("删除失败!");
        }
    }

    //用户信用调整
    public void setStuCredit() throws IOException, ClassNotFoundException {
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        boolean flag = true;
        for (User user : userList) {
            if (String.valueOf(user.getUID()).startsWith("1")) {
                System.out.println(user);
            }
        }
        int credit_rating = 0;
        System.out.println("请输入需要调整的用户编码:");
        String UID = TSUtility.readKeyBoard(4, false);
        for (User user : userList) {
            if (user.getUID() == Integer.parseInt(UID) && UID.startsWith("1")) {
                credit_rating = user.getCredit_rating();
            }
        }
        if (credit_rating == 0) {
            System.out.println("该用户不存在或信誉等级过低,无法修改!");
            return;
        } else {
            for (User user : userList) {
                if (user.getUID() == Integer.parseInt(UID)) {
                    System.out.println("请输入调整后的信用等级(1-5):当前为" + credit_rating + "级");
                    int newCredit = TSUtility.readInt();
                    if (newCredit > 5 || newCredit < 0) {
                        System.out.println("您输入的信誉等级有误!");
                        flag = false;
                        break;
                    } else {
                        user.setCredit_rating(newCredit);
                        flag = true;
                    }
                    break;
                } else {
                    flag = false;
                }
            }
        }
        if (flag) {
            System.out.println("修改成功!");
        } else {
            System.out.println("修改失败!");
        }
        Tool.uSerStu2(userList, LoginView.userFile);
    }

    //逾期费用扣除比例调整
    public void setDeductSalary() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        boolean flag = true;
        for (Job job : jobList) {
            System.out.println(job);
        }
        System.out.println("请输入需要调整的兼职编号:");
        String JID = TSUtility.readKeyBoard(4, false);
        for (Job job : jobList) {
            if (job.getJID() == Integer.parseInt(JID)) {
                System.out.println("请输入调整后的逾期费用扣除比例:");
                String deductSalary = TSUtility.readKeyBoard(3, false);
                job.setDeduct_salary(Integer.parseInt(deductSalary));
                Tool.serJob(jobList);
                flag = true;
                break;
            } else {
                flag = false;
            }
        }
        if (flag) {
            System.out.println("修改成功!");
        } else {
            System.out.println("修改失败!");
        }
    }

    //兼职信息录入
    public void releaseInfo() throws IOException, ClassNotFoundException {
        Properties prop = new Properties();
        Tool.myLoad(prop, JobType);
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        System.out.println("请输入营业执照编号:");
        String JID = TSUtility.readKeyBoard(5, false);
        boolean flag = true;
        for (Job job : jobList) {
            if (JID.equals(String.valueOf(job.getJID()))) {
                flag = false;
            }
        }
        if (!flag) {
            System.out.println("您输入的营业编号已存在!");
        } else {
            System.out.println("请输入公司名称:");
            String company_name = TSUtility.readKeyBoard(10, false);
            System.out.println("请输入岗位名称:");
            String job_name = TSUtility.readKeyBoard(10, false);
            System.out.println("请选择兼职类型:");
            Set<String> names = prop.stringPropertyNames();
            for (String key : names) {
                String value = prop.getProperty(key);
                System.out.println(key + ":" + value);
            }
            int jobTypeNum = TSUtility.readInt();
            String jobType = null;
            for (String key : names) {
                if (key.equals(String.valueOf(jobTypeNum))) {
                    String value = prop.getProperty(key);
                    jobType = String.valueOf(value);
                }
            }
            System.out.println("请输入兼职等级(1-5):");
            String job_level = TSUtility.readKeyBoard(1,false);
            System.out.println("请输入薪水:");
            String salary = TSUtility.readKeyBoard(5, false);
            System.out.println("请输入逾期扣除比例:");
            String deduct_salary = TSUtility.readKeyBoard(3, false);
            System.out.println("请输入工作内容:");
            String job_content = TSUtility.readKeyBoard(10, false);
            System.out.println("请输入工作需求人数:");
            int job_demand = TSUtility.readInt();
            System.out.println("请输入工作时间:");
            String job_time = TSUtility.readKeyBoard(10, false);
            Job job = new Job(Integer.parseInt(JID), company_name, job_name, String.valueOf(jobType), Integer.parseInt(job_level), Integer.parseInt(salary), Integer.parseInt(deduct_salary), job_content, job_demand, Integer.parseInt(job_time));
            jobList.add(job);
            Tool.serJob(jobList);
            System.out.println("兼职信息录入成功!");
        }

    }

    //兼职信息修改
    public void setJobInfo() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        boolean flag = false;
        if (jobList.size() != 0) {
            for (Job job : jobList) {
                System.out.println(job);
            }
            System.out.println("请输入需要修改的营业执照编号:");
            String JID = TSUtility.readKeyBoard(5, false);
            for (Job job : jobList) {
                if (JID.equals(String.valueOf(job.getJID()))) {
                    System.out.println("请输入修改后的薪水:当前薪水为(" + job.getSalary() + "元)");
                    String salary = TSUtility.readKeyBoard(5, false);
                    System.out.println("请输入修改后的需求人数:当前还需(" + job.getJob_demand() + "人)");
                    int job_demand = TSUtility.readInt();
                    job.setSalary(Integer.parseInt(salary));
                    job.setJob_demand(job_demand);
                    flag = false;
                    break;
                } else {
                    flag = true;
                }
            }
        } else {
            System.out.println("暂无兼职信息,请先添加!");
            return;
        }
        if (!flag) {
            System.out.println("兼职信息修改成功!");
        } else {
            System.out.println("修改失败!可能是该信息不存在!");
        }
        Tool.serJob(jobList);
    }

    //为系统录入用户
    public void addIdAndUserName() throws IOException, ClassNotFoundException {
        ArrayList<User> arrayList = Tool.uSerStu(LoginView.idAndUserNameFile);
        System.out.println("请输入需要录入的用户编号:");
        String uid = TSUtility.readKeyBoard(4, false);
        boolean flag = true;
        for (int i = 0; i < arrayList.size(); i++) {
            User user = arrayList.get(i);
            if (uid.equals(String.valueOf(user.getUID()))) {
                flag = false;
            }
        }
        if (!flag) {
            System.out.println("此用户已存在!");
        } else {
            System.out.println("请输入用户姓名:");
            String username = com.guanqia12.view.TSUtility.readKeyBoard(5, false);
            User user = new User(Integer.parseInt(uid), username);
            arrayList.add(user);
            Tool.uSerStu2(arrayList, LoginView.idAndUserNameFile);
            System.out.println("添加成功!");
        }
    }

    //删除管理员
    public void deleteMan(String UID) throws IOException, ClassNotFoundException {
        ArrayList<User> arrayList = Tool.uSerStu(LoginView.userFile);
        boolean flag = true;
        boolean flag1 = true;
        while (flag) {
            for (User user : arrayList) {
                if (String.valueOf(user.getUID()).startsWith("2") && user.getUID() != Integer.parseInt(UID)) {
                    System.out.println(user);
                    flag1 = false;
                }
            }
            if (flag1) {
                System.out.println("无可删除管理员!");
                return;
            }
            System.out.println("请输入您要删除的用户编号:");
            String uid = TSUtility.readKeyBoard(4, false);
            if (uid.equals(UID)) {
                System.out.println("请注意!无法删除自身账户!");
                System.out.println("是否重新输入?y/n");
                char c = TSUtility.readConfirmSelection();
                if (c == 'Y') {
//                    System.out.println("请重新输入您要删除的用户编号");
                } else if (c == 'N') {
                    flag = false;
                }
            } else if (!(uid.startsWith("2"))) {
                System.out.println("此用户不是管理员或不存在");
                break;
            } else {
                for (int i = 0; i < arrayList.size(); i++) {
                    User user = arrayList.get(i);
                    if (uid.equals(String.valueOf(user.getUID()))) {
                        arrayList.remove(i);
                        Tool.uSerStu2(arrayList, LoginView.userFile);
                        System.out.println("删除成功!");
                        flag = false;
                    }
                }
            }
        }
    }

    //删除普通用户
    public void deleteStu() throws IOException, ClassNotFoundException {
        ArrayList<User> arrayList = Tool.uSerStu(LoginView.userFile);
        ArrayList<ApplyJob> applyJObList = Tool.uSerApplyJob(StudentService.applyJob);

        for (User user : arrayList) {
            if (String.valueOf(user.getUID()).startsWith("1")) {
                System.out.println(user);
            }
        }
        System.out.println("请输入您要删除的用户编号:");
        String uid = TSUtility.readKeyBoard(4, false);
        boolean flag = true;
        boolean flag1 = true;
        while (flag) {
            for (int i = 0; i < arrayList.size(); i++) {
                User user = arrayList.get(i);
                if (uid.equals(String.valueOf(user.getUID())) && uid.startsWith("1")) {
                    for (ApplyJob applyJob : applyJObList) {
                        if (applyJob.getUID() == Integer.parseInt(uid) && applyJob.getState() == 1) {
                            System.out.println("该学生有未完成兼职无法删除!");
                            return;
                        }
                    }
                    arrayList.remove(i);
                    Tool.uSerStu2(arrayList, LoginView.userFile);
                    System.out.println("删除成功!");
                    return;
                } else {
                    flag1 = false;
                    flag = false;
                }
            }
        }
        if (!flag1) {
            System.out.println("该用户不存在或不是普通用户!");
        }
    }


    //修改密码
    public void modifyPassword(String UID) throws IOException, ClassNotFoundException, ParseException {
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        System.out.println("请输入修改后的密码:");
        String passWord = TSUtility.readKeyBoard(10, false);
        for (User user : userList) {
            if (user.getUID() == Integer.parseInt(UID)) {
                user.setPassword(passWord);
                Tool.uSerStu2(userList, LoginView.userFile);
                System.out.println("修改成功!");
                l.login();
                break;
            }
        }
    }

    //删除无用兼职信息
    public void deleteJobInfo() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        ArrayList<ApplyJob> applyJobList = Tool.uSerApplyJob(StudentService.applyJob);
        boolean flag = true;
        boolean flag1 = true;
        System.out.println("以下兼职信息可删除:");
        for (Job job : jobList) {
            if (job.getJob_demand() == 0) {
                for (ApplyJob applyJob : applyJobList) {
                    if (job.getJID() == applyJob.getJID() && applyJob.getState() != 1) {
                        System.out.println(job);
                        flag1 = false;
                        break;
                    }
                }
            }
        }
        if (flag1) {
            System.out.println("没有可删除的兼职信息!");
            return;
        }
        System.out.println("请输入需要删除的兼职编号:");
        String JID = TSUtility.readKeyBoard(4, false);
        for (Job job : jobList) {
            if (job.getJID() == Integer.parseInt(JID)) {
                jobList.remove(job);
                flag = false;
                break;
            }
        }
        for (ApplyJob applyJob : applyJobList) {
            if (applyJob.getJID() == Integer.parseInt(JID)) {
                applyJobList.remove(applyJob);
                break;
            }
        }
        if (!flag) {
            System.out.println("删除成功!");
        } else {
            System.out.println("删除失败!");
        }
    }

    //查询用户
    public void selectUser() throws IOException, ClassNotFoundException {
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        for (User user : userList) {
            if (String.valueOf(user.getUID()).startsWith("1")) {
                System.out.println(user);
            }
        }
    }

    //查询管理员
    public void selectAdministrator() throws IOException, ClassNotFoundException {
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        for (User user : userList) {
            if (String.valueOf(user.getUID()).startsWith("2")) {
                System.out.println(user);
            }
        }
    }

    //查询已投放兼职
    public void selectAllJob() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(JobList);
        if (jobList.size() != 0) {
            for (Job job : jobList) {
                System.out.println(job);
            }
        } else {
            System.out.println("暂无兼职信息!");
        }
    }

    //查询已完成兼职
    public void selectCompleteJob() throws IOException, ClassNotFoundException {
        ArrayList<ApplyJob> applyJobList = Tool.uSerApplyJob(StudentService.applyJob);
        boolean flag = true;
        if (applyJobList.size() != 0) {
            for (ApplyJob applyJob : applyJobList) {
                if (applyJob.getState() > 1) {
                    System.out.println(applyJob);
                    flag = false;
                }
            }
        }
        if (flag) {
            System.out.println("暂无已完成兼职!");
        }
    }

    //查询逾期兼职
    public void selectOverdueJob() throws IOException, ClassNotFoundException {
        ArrayList<ApplyJob> applyJobList = Tool.uSerApplyJob(StudentService.applyJob);
        boolean flag = true;
        if (applyJobList.size() != 0) {
            for (ApplyJob applyJob : applyJobList) {
                if (applyJob.getState() == 3) {
                    System.out.println(applyJob);
                    flag = false;
                }
            }
        }
        if (flag) {
            System.out.println("无逾期兼职!");
        }
    }
}

StudentService

package com.guanqia16.service;

import com.guanqia16.Util.TSUtility;
import com.guanqia16.Util.Tool;
import com.guanqia16.domain.ApplyJob;
import com.guanqia16.domain.Job;
import com.guanqia16.domain.User;
import com.guanqia16.view.LoginView;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class StudentService {
    String jobList = "idea_test\\src\\com\\guanqia16\\File\\jobList.txt";
    public static String applyJob = "idea_test\\src\\com\\guanqia16\\File\\applyJob.txt";

    //查询所有兼职信息
    public void applyAllWork() throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(this.jobList);
        if (jobList.size() != 0) {
            for (Job job : jobList) {
                System.out.println(job);
            }
        } else {
            System.out.println("暂无兼职信息,请等待管理员添加!");
        }
    }

    //可申请兼职(是否可申请与信用等级、岗位所需人员、兼职时间相关)
    public void mayApplyJob(String uid) throws IOException, ClassNotFoundException {
        ArrayList<Job> jobList = Tool.uSerJob(this.jobList);
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        int credit = 0;
        for (User user : userList) {
            if (user.getUID() == Integer.parseInt(uid)) {
                credit = user.getCredit_rating();
            }
        }
        for (Job job : jobList) {
            if (credit >= job.getJob_level() && job.getJob_demand() > 0) {
                System.out.println(job);
            }
        }
    }

    //已完成兼职
    public void completeJob(String UID) throws IOException, ClassNotFoundException {
        ArrayList<ApplyJob> applyJobs = Tool.uSerApplyJob(applyJob);
        for (ApplyJob applyJob : applyJobs) {
            if (applyJob.getUID() == Integer.parseInt(UID) && applyJob.getState() == 2 || applyJob.getState() == 3) {
                System.out.println(applyJob);
            }
        }
    }

    //正在兼职
    public void doingJob(String uid) throws IOException, ClassNotFoundException {
        ArrayList<ApplyJob> applyJobs = Tool.uSerApplyJob(applyJob);
        for (ApplyJob applyJob : applyJobs) {
            if (applyJob.getUID() == Integer.parseInt(uid) && applyJob.getState() == 1) {
                System.out.println(applyJob);
            }
        }
    }

    //申请工作
    public void ApplyJob(String uid, String password) throws IOException, ClassNotFoundException {
        mayApplyJob(uid);
        ArrayList<ApplyJob> applyJobs = Tool.uSerApplyJob(applyJob);
        boolean flag = true;
        System.out.println("请输入需要申请的兼职JID:");
        String JID = TSUtility.readKeyBoard(4, false);
        for (ApplyJob applyJob : applyJobs) {
            if (applyJob.getJID() == Integer.parseInt(JID) && applyJob.getState() == 1) {
                System.out.println("您已申请该兼职,该兼职未完成无法重复申请!");
                return;
            }
        }
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        ArrayList<Job> jobList = Tool.uSerJob(this.jobList);
        for (User user : userList) {
            if (user.getUID() == Integer.parseInt(uid)) {
                for (Job job : jobList) {
                    if (job.getJID() == Integer.parseInt(JID) && job.getJob_demand() > 0) {
                        if (job.getJob_level()>user.getCredit_rating()){
                            System.out.println("您的信誉等级过低,无法申请该工作!");
                            return;
                        }
                        int job_time = job.getJob_time();
                        System.out.println("请输入兼职开始时间格式为(yyyy-MM-dd):");
                        String startTime = TSUtility.readKeyBoard(10, false);
                        ApplyJob applyJob = new ApplyJob(Integer.parseInt(uid), Integer.parseInt(JID),job_time, startTime, null, 1);
                        applyJobs.add(applyJob);
                        Tool.serApplyJob(applyJobs);
                        System.out.println("申请成功,请在规定时长内完成兼职!");
                        int job_demand = job.getJob_demand();
                        job_demand--;
                        job.setJob_demand(job_demand);
                        Tool.serJob(jobList);
                        return;
                    } else {
                        flag = false;
                    }
                }
            }

        }
        if (!flag) {
            System.out.println("输入错误!");
        }

    }

    //结束工作
    public void FinishWord(String uid) throws IOException, ClassNotFoundException, ParseException {
        ArrayList<ApplyJob> applyJobs = Tool.uSerApplyJob(applyJob);
        doingJob(uid);
        ArrayList<Job> jobList = Tool.uSerJob(this.jobList);
        ArrayList<User> userList = Tool.uSerStu(LoginView.userFile);
        boolean flag = true;
        boolean flag1 = true;
        for (ApplyJob applyJob : applyJobs) {
            if (applyJob.getUID() == Integer.parseInt(uid) && applyJob.getState() == 1) {
                flag1 = false;
            }
        }
        if (flag1) {
            System.out.println("暂无需要结束的兼职!");
            return;
        }
        System.out.println("请输入需要结束的工作编号:");
        String JID = TSUtility.readKeyBoard(4, false);
        for (ApplyJob applyJob : applyJobs) {
            if (applyJob.getJID() == Integer.parseInt(JID) && applyJob.getUID() == Integer.parseInt(uid) && applyJob.getState() == 1) {
                boolean flag2 = true;
                double time = 0.0;
                while (flag2) {
                    System.out.println("请输入结束时间格式为(yyyy-MM-dd):");
                    String endTime = TSUtility.readKeyBoard(10, false);
                    String startTime = applyJob.getWork_start();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    Date endTime1 = sdf.parse(endTime);
                    Date startTime1 = sdf.parse(startTime);
                    time = (endTime1.getTime() - startTime1.getTime()) * 1.0 / 1000 / 60 / 60 / 24;
                    if (time < 0.0) {
                        System.out.println("您输入的时间有误!请重新输入!");
                    } else {
                        flag2 = false;
                    }
                }
                int salary = 0;
                int deduct_salary = 0;
                int job_time = 0;
                for (Job job : jobList) {
                    if (job.getJID() == Integer.parseInt(JID)) {
                        salary = job.getSalary();
                        deduct_salary = job.getDeduct_salary();
                        job_time = job.getJob_time();
                    }
                }
                if (time > job_time) {
                    applyJob.setState(3);
                } else {
                    applyJob.setState(2);
                }
                Tool.serApplyJob(applyJobs);
                for (User user : userList) {
                    if (user.getUID() == Integer.parseInt(uid)) {
                        if (time > job_time) {
                            salary = salary + ((int) time - job_time) * deduct_salary;
                        }
                        if (salary > 0) {
                            user.setBalance(user.getBalance() + salary);
                        }
                        if (time>job_time) {
                            int credit_rating = user.getCredit_rating();
                            user.setCredit_rating(credit_rating - 1);
                        } else if (applyJob.getState() == 2) {
                            if (user.getCredit_rating() < 5) {
                                int count = user.getCount();
                                if (count == 1) {
                                    user.setCredit_rating(user.getCredit_rating() + 1);
                                    user.setCount(3);
                                } else if (count > 1) {
                                    user.setCount(user.getCount() - 1);

                                }
                            }
                            Tool.uSerStu2(userList, LoginView.userFile);
                            System.out.println("工作已完成结束!");
                            return;
                        }
                    }
                }
            }
        }
    }

}

总的来说,只要把各个功能之间的关系理清楚了,写起来还是不难的。我在其中多次用到了序列化和反序列化,还有io流的相关知识,当然问题也是有的,就比如我遇到了空指针异常还有因为定义的时候的数据类型没定义好,导致后面操作数据时要进行多次的数据类型转换。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值