溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Java程序模擬公安局人員管理系統(tǒng)-----來自狼騰測(cè)試員

發(fā)布時(shí)間:2020-07-30 18:32:26 來源:網(wǎng)絡(luò) 閱讀:346 作者:Jasonisoft 欄目:編程語言
                                                            Java 
  1. 編程題:公安人員的管理系統(tǒng)
    1) 學(xué)生類:
    a) 屬性:
    i. 身份號(hào)—默認(rèn)沒有,需要手動(dòng)進(jìn)行輸入
    ii. 姓名
    iii. 性別
    iv. 年齡
    v. 密碼
    vi. 居住地址
    vii. 注冊(cè)日期
    viii. 人員的信譽(yù)程度(
    1. 0:無犯罪歷史,
    2. 1:有過輕度犯罪歷史
    3. 2:嚴(yán)重犯罪歷史
    4. 3:殺人罪但是有期徒刑
    5. 4:殺人罪并執(zhí)行死刑
    6. 5:個(gè)人榮譽(yù)小貼士
    7. 6:國(guó)家級(jí)別榮譽(yù)獎(jiǎng)?wù)拢?br/>ix. 文化程度(
    8. 0:沒有教育歷史(包括幼兒園)
    9. 1:小學(xué)文化
    10. 2:初中文化
    11. 3:高中文化
    12. 4:大學(xué)文化(碩士生)
    13. 5:研究生
    14. 6:博士生
    15. 7:教授)
      --默認(rèn)是沒有教育歷史
      x. 學(xué)習(xí)次數(shù)

b) 行為:
i. 學(xué)習(xí):

  1. 傳入的內(nèi)容是從學(xué)習(xí)類列表中隨機(jī)抽取,也可以自己輸入學(xué)習(xí)編號(hào)
  2. 邏輯:先判斷學(xué)習(xí)的上一級(jí)內(nèi)容是否已經(jīng)達(dá)到,如果達(dá)到則學(xué)習(xí),并將本對(duì)象的文化程度修改為相對(duì)應(yīng)的級(jí)別,如果沒達(dá)到,則拋出學(xué)歷級(jí)別未達(dá)到異常。學(xué)習(xí)完后則學(xué)習(xí)次數(shù)可以加1
    2) 學(xué)習(xí)類列表:
    a) 可學(xué)習(xí)的內(nèi)容如下
    i. 小學(xué)課本
    ii. 高中課本
    iii. 大學(xué)課本
    iv. 研究生課本
    v. 博士生課本
    vi. 教授課本
    vii. 廚師技能
    viii. 修汽車技能

3) 本地公安局類:
a) 屬性:公安局人員備案庫(最大存儲(chǔ)200個(gè))
b) 移民:(傳入當(dāng)前用戶的對(duì)象)

  1. 先判斷當(dāng)前公安局人員備案庫里是否存在當(dāng)前用戶
    a) 沒有的話則打印您是未成年人還不能移民,
    b) 若有則判斷當(dāng)前的人員的信譽(yù)程序是否有無犯罪歷史
    i. 有的話則不能移民,
    ii. 若沒有犯罪歷史,

    1. 再判斷文化程度是否達(dá)到大學(xué)文化
      a) 沒有則需要再等待1年審核時(shí)間
      b) 若達(dá)到大學(xué)文化,則可以移民,并將本地公安局和國(guó)家人員管理庫的當(dāng)前人員永久刪除。
      4) 國(guó)家人員管理庫:
      a) 屬性:全國(guó)國(guó)家安全總局人員備案庫(最大存儲(chǔ)3000000)
      b) 行為:
      i. 查詢?nèi)藛T:

      1. 邏輯:傳入人員的對(duì)象,并判斷當(dāng)前是否存在,不存在返回false,存在返回true;
        ii. 人員的入庫:
      2. 邏輯:傳入人員對(duì)象
        a) 先看當(dāng)前庫是否存在,若存在則打印已存在,否則注冊(cè)
        iii. 人員的刪除
      3. 邏輯:傳入人員對(duì)象
        a) 則先看是否存在,若存在則刪除,不存在則打?。喝藛T身份未備案

                                                        答案:

1.系統(tǒng)目錄展示:
Java程序模擬公安局人員管理系統(tǒng)-----來自狼騰測(cè)試員
2.Address類:
package cn.letter.address;

    public class Address {
    private String country;
    private String province;
    private String street;
    private String houseNumber;

public Address() {

}

public Address(String country, String province, String street,
        String houseNumber) {
    this.country = country;
    this.province = province;
    this.street = street;
    this.houseNumber = houseNumber;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public String getProvince() {
    return province;
}

public void setProvince(String province) {
    this.province = province;
}

public String getStreet() {
    return street;
}

public void setStreet(String street) {
    this.street = street;
}

public String getHouseNumber() {
    return houseNumber;
}

public void setHouseNumber(String houseNumber) {
    this.houseNumber = houseNumber;
}

}

3.TextBook類:
package cn.letter.study;

public class Textbook {
    private String[] course={"小學(xué)課本","初中課本","高中課本","大學(xué)課本","研究生課本","博士生課本","教授課本"};

public String[] getCourse() {
    return course;
}

public void setCourse(String[] course) {
    this.course = course;
}

}

4.Person類:
package cn.letter.User;

import java.text.SimpleDateFormat;
import java.util.Date;

import cn.letter.address.Address;
import cn.lttest.uitl.ScannerHelp;
import cn.lttest.uitl.UUIDutil;

public class Person {
    private String ID;
    private String name;
    private char sex;
    private int age;
    private String password;
    private Boolean state;
    private Address address;
    private Date date;
    private Date applyDate;
    private int reputation;
    private int culture;
    private int study;
    private String[] repu = { "無犯罪歷史", "有過輕度犯罪歷史", "嚴(yán)重犯罪歷史", "殺人罪但是有期徒刑",
            "殺人罪并執(zhí)行死刑", "個(gè)人榮譽(yù)小貼士", "國(guó)家級(jí)別榮譽(yù)獎(jiǎng)?wù)?" };
            private String[] cul = { "沒有教育歷史", "小學(xué)文化", "初中文化", "高中文化", "大學(xué)文化(碩士生)",
                    "研究生", "博士生", "教授" };

public String getID() {
    return ID;
}

public void setID(String iD) {
    ID = iD;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public char getSex() {
    return sex;
}

public void setSex(char sex) {
    this.sex = sex;
}

public int getAge() {
    return age;
}

public void setAge(int age) {
    this.age = age;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public Address getAddress() {
    return address;
}

public void setAddress(Address address) {
    this.address = address;
}

public Boolean getState() {
    return state;
}

public String getDate() {
    return new SimpleDateFormat("yyyy-MM-dd").format(date);
}

public void setApplyDate(Date applyDate) {
    this.applyDate = applyDate;
}

public String getApplyDate() {
    return applyDate == null ? "" : new SimpleDateFormat("yyyy-MM-dd")
            .format(applyDate);
}

public int getReputation() {
    return reputation;
}

public int getCulture() {
    return culture;
}

public int getStudy() {
    return study;
}

public String[] getCul() {
    return cul;
}

public String[] getRepu() {
    return repu;
}

public Person(String name, char sex, int age, String password,
        Address address) {
    super();
    ID = UUIDutil.UUID();
    this.name = name;
    this.sex = sex;
    this.age = age;
    this.password = password;
    this.state = true;
    this.address = address;
    this.date = new Date();
    this.reputation = 0;
    this.culture = 0;
    this.study = 0;
}

public Person() {

}

public void stud() {
    int stu = ScannerHelp.getInt("課本");
    if (stu < culture) {
        study++;
    } else if (stu == culture) {
        study++;
        culture++;
    } else
        System.out.println("學(xué)歷級(jí)別未達(dá)到!");
    if (culture > 3) {
        if (culture == 7)
            reputation = 6;
        else
            reputation = 5;
    }
    System.out.println("當(dāng)前學(xué)歷:" + getCul()[getCulture()]);
}

}

5.學(xué)生類:
package cn.letter.User;

import cn.letter.address.Address;

public class Student extends Person {

public Student() {
}

public Student(String name, char sex, int age, String password,
        Address address) {
    super(name, sex, age, password, address);
}

@Override
public String toString() {
    return "人員身份號(hào):" + getID() + "\n姓名:" + getName() + "\n性別:" + getSex()
            + "\n年齡:" + getAge() + "\n密碼:" + getPassword() + "\n國(guó)家:"
            + getAddress().getCountry() + "\n地區(qū):"
            + getAddress().getProvince() + "\n街道:"
            + getAddress().getStreet() + "\n門牌號(hào):"
            + getAddress().getHouseNumber() + "\n注冊(cè)日期:" + getDate()
            + "\n信譽(yù)程度:" + getRepu()[getReputation()] + "\n文化程度:"
            + getCul()[getCulture()] + "\n學(xué)習(xí)次數(shù):" + getStudy();
}

}

6.本地公安局類:
package cn.lttest.country;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import cn.letter.User.Student;

public class AddressPerson {
    static Student[] stu = new Student[200];
    static Country coun = new Country();
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

public static Student[] getStu() {
    return stu;
}

public static void setStu(Student[] stu) {
    AddressPerson.stu = stu;
}

public static void move(String name) {
    boolean chose = false;
    int ch = 0;
    long time = 0;
    String eq = "";
    System.out.println(stu[0].getApplyDate());
    for (int i = 0; i < stu.length; i++) {
        if (stu[i].getName() != null && stu[i].getName().equals(name)) {
            ch = i;
            if (stu[i].getReputation() == 0 || stu[i].getReputation() == 5
                    || stu[i].getReputation() == 6) {
                if (stu[i].getCulture() < 4) {
                    if (stu[i].getApplyDate().equals(eq)) {
                        stu[i].setApplyDate(new Date());
                        System.out.println("需要審核時(shí)間一年");
                        break;
                    } else {
                        try {
                            time = (sdf.parse(stu[i].getApplyDate())
                                    .getTime() - sdf
                                    .parse(stu[i].getDate()).getTime())
                                    / 1000 / 60 / 60 / 24;
                            break;
                        } catch (ParseException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                    if (time < 365) {
                        System.out.println("需要審核時(shí)間" + time + "天");
                        break;
                    } else {
                        chose = true;
                        break;
                    }

                } else {
                    chose = true;
                    break;
                }

            } else {
                System.out.println("有犯罪歷史,無法移民");
                break;
            }
        } else {
            System.out.println("您是未成年人,不能移民");
            break;
        }
    }
    if (chose == true) {
        stu[ch] = null;
        for (int j = 0; j < stu.length; j++) {
            if (coun.stu[j].getName() != null && coun.stu[j].getName().equals(name)) {
                System.out.println("移民成功!");
                coun.stu[j] = null;
                break;
            }
        }
    }
}

public static boolean isExists(String name){
    if (name == null) {
        return true;
    }

    for (int i = 0; i < stu.length; i++) {
        if (stu[i].getName().equals(name)) {
            return false;
        }
    }

    return true;
}
}

7.國(guó)家人員庫類:
package cn.lttest.country;

import cn.letter.User.Person;
import cn.letter.User.Student;
import cn.letter.address.Address;
import cn.letter.study.Textbook;
import cn.lttest.uitl.ScannerHelp;

public class Country {

static Person[] stu = new Person[3000000];
static AddressPerson addr = new AddressPerson();
static Textbook tk = new Textbook();

public static Person[] getStu() {
    return stu;
}

public static void setStu(Student[] stu) {
    Country.stu = stu;
}

public void addUser(Student use) {
    for (int i = 0; i < stu.length; i++) {
        if (stu[i] != null && stu[i] == use) {
            System.out.println("已存在");
            break;
        } else if (stu[i] == null) {
            stu[i] = use;
            System.out.println("人員入庫成功!");
            break;
        }
    }
    for (int i = 0; i < addr.stu.length; i++) {
        if (addr.stu[i] != null && addr.stu[i] == use) {
            break;
        } else if (addr.stu[i] == null) {
            addr.stu[i] = use;
            break;
        }
    }
}

public void delUser(String name) {
    boolean chose = false;
    for (int i = 0; i < stu.length; i++) {
        if (stu[i] != null && stu[i].getName().equals(name)) {
            stu[i] = null;
            chose = true;
            break;
        }
    }
    System.out.println(chose == true ? "已刪除" : "人員身份未備案");
}

public void showUser(String name) {
    int j = 0;
    boolean chose = false;
    for (int i = 0; i < stu.length; i++) {
        if (stu[i] != null && stu[i].getName().equals(name)) {
            j = i;
            chose = true;
            break;
        }
    }
    System.out.println(chose == true ? "人員身份號(hào):" + stu[j].getID() + "\n姓名:"
            + stu[j].getName() + "\n性別:" + stu[j].getSex() + "\n年齡:"
            + stu[j].getAge() + "\n密碼" + stu[j].getPassword() + "\n居住地址"
            + stu[j].getAddress() + "\n注冊(cè)日期" + stu[j].getDate() + "\n信譽(yù)程度"
            + stu[j].getRepu()[stu[j].getReputation()] + "\n文化程度"
            + stu[j].getCul()[stu[j].getCulture()] + "\n學(xué)習(xí)次數(shù)"
            + stu[j].getStudy() : "人員身份為備案");
}

public Student add() {
    String name = ScannerHelp.getString("姓名");
    char sex = ' ';
    while (true) {
        System.out.println("1:男\(zhòng)t2:女");
        int sexx = ScannerHelp.getInt("性別");
        if (sexx == 1) {
            sex = '男';
            break;
        } else if (sexx == 2) {
            sex = '女';
            break;
        } else
            System.out.println("輸入錯(cuò)誤,請(qǐng)重新輸入!");
    }
    int age = ScannerHelp.getInt("年齡");
    String password = "";

    while (true) {
        System.out.println("密碼為6-12位");
        password = ScannerHelp.getString("密碼");
        if (password.length() > 12 || password.length() < 6)
            System.out.println("輸入錯(cuò)誤,請(qǐng)重新輸入!");
        else
            break;
    }

    String country = ScannerHelp.getString("國(guó)家");
    String province = ScannerHelp.getString("地區(qū)");
    String street = ScannerHelp.getString("街道");
    String door = ScannerHelp.getString("門牌號(hào)");
    Address addr = new Address(country, province, street, door);
    Student stu = new Student(name, sex, age, password, addr);
    return stu;
}

public void study(String name) {
    for (int i = 0; i < stu.length; i++) {
        if (stu[i] != null && stu[i].getName().equals(name)) {
            stu[i].stud();
            break;
        }
    }
}
}

8.輸入幫助類:
package cn.lttest.uitl;

import java.util.Scanner;

public class ScannerHelp {
    static Scanner sc = new Scanner(System.in);

/**
 * 幫助我們輸入整型數(shù)據(jù)
 * 
 * @param name
 * @return
 */
public static int getInt(String name) {
    System.out.print("請(qǐng)輸入" + name + ":");
    int num = sc.nextInt();
    sc.nextLine();
    return num;
}

/**
 * 幫助我們輸入字符串
 * 
 * @param name
 * @return
 */
public static String getString(String name) {
    System.out.print("請(qǐng)輸入" + name + ":");
    String num = sc.nextLine();
    return num;
}

}

9.隨機(jī)獲取類:
package cn.lttest.uitl;

import java.util.Random;

public class UUIDutil {
    static Random random = new Random();

public static String UUID() {
    String ID = "";
    char[] id = new char[62];
    for (int i = 0; i < 10; i++) {
        id[i] = (char) (48 + i);
    }
    for (int i = 10, j = 10; i < 62; i++, j++) {
        id[i] = (char) (55 + j);
        id[i + 1] = (char) (55 + 32 + j);
        i++;
    }
    for (int i = 0; i < 32; i++) {
        ID += id[random.nextInt(62)];
    }
    return ID;
}

}

10.視圖類全局程序入口:
package cn.letter.View;

import java.util.Scanner;

import cn.letter.User.Student;
import cn.lttest.country.AddressPerson;
import cn.lttest.country.Country;
import cn.lttest.uitl.ScannerHelp;

public class View {
    static Student stud = new Student();
    static Country coun = new Country();
    static AddressPerson add = new AddressPerson();
    static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
    while (true) {
        System.out.println("*****************************");
        System.out.println("\t      公安局\n\t      人員注冊(cè)系統(tǒng)\n\t    V1.0");
        System.out.println("*****************************");
        System.out.print("\t1.人員入庫");
        System.out.println("\t2.人員刪除");
        System.out.print("\t3.移民");
        System.out.println("\t4.學(xué)習(xí)");
        System.out.print("\t5.查詢");
        System.out.println("\t6.退出\n請(qǐng)輸入您的選擇:");
        int ch = sc.nextInt();
        switch (ch) {
        case 1:
            coun.addUser(coun.add());
            break;

        case 2:
            coun.delUser(ScannerHelp.getString("姓名"));
            break;
        case 3:
            add.move(ScannerHelp.getString("姓名"));
            break;
        case 4:
            coun.study(ScannerHelp.getString("姓名"));
            break;
        case 5:
            coun.showUser(ScannerHelp.getString("姓名"));
            break;
        case 6:
            System.out.println("bye!");
            break;

        default:
            System.out.println("輸入有誤,請(qǐng)重新輸入!");
            /*
             * for (int i = 0; i < coun.getStu().length; i++) { if
             * (coun.getStu()[i] != null)
             * System.out.println(coun.getStu()[i].toString()); else
             * System.out.print(""); }
             */
            break;
        }
        //
        for (int i = 0; i < coun.getStu().length; i++) {
            if (coun.getStu()[i] != null
                    && coun.getStu()[i].getReputation() == 4) {
                coun.delUser(coun.getStu()[i].getName());
            } else
                System.out.print("");
        }
        if (ch == 6) {
            break;
        }
    }
}

}

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI