IDEA+Java console to realize pet management system [recommended collection]

Posted by akforce on Sun, 21 Nov 2021 06:59:44 +0100

catalogue

1, System introduction

1. Development environment

2. Technical selection

3. System functions

4. Access to resources

2, System display  

1. Log in to the system

2. Query pet information

3. Add pet information

4. Update pet information

5. Delete pet information

3, Partial code

BusinessService

LoginService

  4, Other

1. Other system implementation

2. Access to source code

3. Operation project

4. Remarks

5. Support bloggers

1, System introduction

1. Development environment

Development tool: IDEA2018.2

JDK version: jdk1.8

2. Technical selection

java language development, using ArrayList to store information.

3. System functions

1. Realize system login

2. Add, delete, modify and check pet information

4. Access to resources

1.CSDN Download

Java implementation console pet management system - Java document resources - CSDN download Java implementation console pet management system to realize login, addition, deletion, modification and query. The system has been tested for many times and runs correctly. Please rest assured to download. For more download resources and learning materials, please visit CSDN download channelhttps://download.csdn.net/download/helongqiang/21048417

2. Free access

Pay attention to WeChat official account and contact me with WeChat.

2, System display  

1. Log in to the system

 

2. Query pet information

 

3. Add pet information

 

4. Update pet information

 

5. Delete pet information

 

3, Partial code

BusinessService

package service;

import common.Constant;
import common.Response;
import entity.Pet;

import java.util.ArrayList;
import java.util.List;

public class BusinessService {

    private static List<Pet> businessList = new ArrayList<>();

    static {
        businessList.add(new Pet("1","kitten","male","2","2"));
        businessList.add(new Pet("2","puppy","male","2","2"));
        businessList.add(new Pet("3","Rabbit","male","2","2"));

    }

    // query
    public Response query(String name){
        if(name == null || "".equals(name)){
            return new Response("error","The number is empty.");
        }
        for(Pet pet : businessList){
            if(name.equals(pet.getPetId())){
                return new Response("success","Query succeeded.", pet);
            }
        }
        return new Response("error","Not found here"+ Constant.MAIN_CLASS +",Please re-enter:");
    }

    // increase
    public Response add(Pet pet){
        for(Pet p : businessList){
            if(p.getPetId().equals(pet.getPetId())){
                return new Response("error","Should"+ Constant.MAIN_CLASS+"Already exists.");
            }
        }
        businessList.add(pet);
        return new Response("success", Constant.MAIN_CLASS+"Added successfully.", pet);
    }

    // edit
    public Response checkProp(Pet pet, String prop, String value){
        if(prop == null || "".equals(prop)){
            return new Response("error","Property is empty.");
        }
        String[] props = {"petId","petName","petSex","petAge","petWeight"};
        switch(prop){
            case "petId" :
                pet.setPetId(value);
                break;
            case "petName" :
                pet.setPetName(value);
                break;
            case "petSex" :
                pet.setPetSex(value);
                break;
            case "petAge" :
                pet.setPetAge(value);
                break;
            case "petWeight" :
                pet.setPetWeight(value);
                break;
            default:
                return new Response("error","The property does not exist.");
        }
        return new Response("success","Edit succeeded.");
    }

    // delete
    public Response delete(String name){
        if(name == null || "".equals(name)){
            return new Response("error", Constant.MAIN_CLASS+"The number is empty.");
        }
        for(Pet pet: businessList){
            if(pet.getPetId().equals(name)){
                businessList.remove(pet);
                return new Response("success", Constant.MAIN_CLASS+"Deletion succeeded.");
            }
        }
        return new Response("error", Constant.MAIN_CLASS+"non-existent.");
    }

}

LoginService

package service;

import common.Account;
import common.Response;
import entity.User;

import java.util.ArrayList;
import java.util.List;

public class LoginService {

    private static List<User> userList = new ArrayList();

    static{
        userList.add(new User(Account.ADMIN.getUsername(), Account.ADMIN.getPassword()));
        userList.add(new User(Account.USER1.getUsername(), Account.USER1.getPassword()));
        userList.add(new User(Account.USER2.getUsername(), Account.USER2.getPassword()));
        userList.add(new User(Account.USER3.getUsername(), Account.USER3.getPassword()));
    }

    public Response login(String username, String password){
        if(username == null || "".equals(username)){
            return new Response("error","The user name is empty, please enter the user name.");
        }
        if(password == null || "".equals(password)){
            return new Response("error","The password is blank, please enter the password.");
        }
        for (User user : userList){
            if(username.equals(user.getUsername()) && password.equals(user.getPassword())){
                return new Response("success","Login succeeded!");
            }
        }
        return new Response("error","The user name or password is entered incorrectly. Please check and re-enter.");
    }

}

  4, Other

1. Other system implementation

2. Access to source code

Click the following link to get the source code.

Java implementation console pet management system - Java document resources - CSDN download Java implementation console pet management system to realize login, addition, deletion, modification and query. The system has been tested for many times and runs correctly. Please rest assured to download. For more download resources and learning materials, please visit CSDN download channelhttps://download.csdn.net/download/helongqiang/21048417

3. Operation project

Directly import the project, open Main and run the program.

4. Remarks

If there is infringement, please contact me to delete.

5. Support bloggers

If you think this article is helpful to you, please pay attention to it. I wish you a happy life! For other resources, you can focus on the official account of the left WeChat public.

 

Topics: Java arraylist IDEA