This is the sixth day of my participation in the August More text Challenge. For details, see: August More Text Challenge

takeaway

Well I admit that I really is adopted: (can’t it’s not a way to test it in the review, so for fans of this system is in a hurry, really can’t even without a graphical interface, you can add: ha, ha, ha, if need $can plus I wrote this is directly in the database. TXT inside, good is said to this, Come on for the exam.

Function is introduced

Main Module introduction

public static void add_info(a)// Add a device module
public static void delete_info(String ID)// Delete the device module
public static void modify_info(String ID)// Modify the device information module
public static info find_info(String ID)// Find the device information module
public static void file(a) throws IOException// Write information to the file module

Copy the code

The delete module takes each object in the list and iterates through it to find the corresponding ID number and then deletes the device with that ID number

The demo interface

The source code

package java_Curriculum_design;
import java.util.*;
import java.io.*;
public class Equipment_management {
    static ArrayList<info> arr=new ArrayList<info>();
    static info node;
    public static void output_info(info in){
        System.out.println("Equipment storage time \ | \ \ t t t t | | \ t into the counter number \ \ t equipment level is in the library \ | \ \ t t t | t \ \ t is used when the time \ | t \ \ t t use information");
        System.out.println(in.ID+"\t\t "+in.deposit_time+"\t\t\t"+in.counter_num+"\t\t\t\t"+in.grade+"\t\t"+in.state+"\t\t\t\t"+in.use_time+"\t\t\t\t\t"+in.use_name_phone);

    }
    public static void delete_info(String ID){
        for(int i=0; i<arr.size(); i++){if(ID.equals(arr.get(i).ID)){ arr.remove(i); System.out.println(arr.get(i).ID); }}}public static void modify_info(String ID){
        for(int i=0; i<arr.size(); i++){if(ID.equals(arr.get(i).ID)){
                arr.remove(i);
                System.out.println("Please re-enter the device information:"); add_info(); }}}public static info find_info(String ID){
        boolean a=false;
        for(int i=0; i<arr.size(); i++){if(ID.equals(arr.get(i).ID)){
                output_info(arr.get(i));
                a=true;
                break; }}if(a==false){
            System.out.println("No such equipment!!");
        }
        return node;
    }
    public static void add_info(a){
        Scanner sc=new Scanner(System.in);
        System.out.println("Please enter the device number:");
        String ID=sc.next();
        System.out.println("Please enter the placement time (format: year. Month.) :");
        String time=sc.next();
        System.out.println("Please enter the level of equipment performance (S,A,B,C,D) :");
        String grade=sc.next();
        System.out.println("Please enter the counter number of the place to be placed:");
        int counter=sc.nextInt();
        System.out.println("Please enter whether the device is in the library (true or False) :");
        boolean state=sc.nextBoolean();
        System.out.println("Please enter the time of use:");
        String use_time=sc.next();
        System.out.println("Please enter the user's information (name + phone number)");
        String use_name_time=sc.next();
        info ans=new info(ID,time,counter,grade,state,use_time,use_name_time);
        arr.add(ans);
    }
    public static void display(a){
        System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
        System.out.println("~ ## Internet of Things Device Management System ## ~");
        System.out.println("~1. Add a device ~");
        System.out.println("~2. Find the device ~");
        System.out.println("~3. Modify device information ~");
        System.out.println("~4. Delete device information ~");
        System.out.println("~ 5. Quit!");
        System.out.println("~ ~");
        System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");

    }
    public static void file(a) throws IOException {
        File f=new File("Internet of Things devices.txt");
        if(! f.exists()){ f.createNewFile(); } FileWriter W=new FileWriter(f,true);
        StringBuffer write=new StringBuffer();
        for(info s:arr){
            write.append(s.ID+"");
            write.append(s.deposit_time+"");
            write.append(s.counter_num+"");
            write.append(s.grade+"");
            write.append(s.state+"");
            write.append(s.use_time+"");
            write.append(s.use_name_phone+"");
            String xinxi=write.toString();
            W.write(xinxi+"\n");
        }
        W.close();
    }
    public static void main(String []args) throws IOException {
        Scanner sc=new Scanner(System.in);
        boolean tmp=true;

        while (tmp==true){
            System.out.println("\n\n");
            display();
            System.out.println("Please enter the function you want to implement:");
            switch (sc.nextInt()){
                case 1:
                    System.out.println("Please enter the number to be stored:");
                    int num=sc.nextInt();
                    for(int i=0; i<num; i++){ System.out.println("\n************");
                        add_info();
                    }
                    tmp=true;
                    break;
                case 2:
                    System.out.println("Please enter the number of the device you want to find:");
                    String ans=sc.next();
                    find_info(ans);
                    tmp=true;
                    break;
                case 3:
                    System.out.println("Please enter the device number to be modified:");
                    ans=sc.next();
                    modify_info(ans);
                    tmp=true;
                    break;
                case 4:
                    System.out.println("Please enter the device number you want to delete:");
                    ans=sc.next();
                    delete_info(ans);
                    tmp=true;
                    break;
                case 5:
                    file();
                    tmp=false;
                    break; }}}}class info{
    String ID;
    String deposit_time;
    int counter_num;// Where is it
    String grade;
    boolean state;// Whether it is in the library
    String use_time;
    String use_name_phone;
    public info(String ID,String deposit_time,int counter_num,String grade,boolean state,String use_time,String use_name_phone){
        this.ID=ID;
        this.deposit_time=deposit_time;
        this.counter_num=counter_num;
        this.grade=grade;
        this.state=state;
        this.use_time=use_time;
        this.use_name_phone=use_name_phone; }}Copy the code