Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write the code of personnel information management system implemented by java

Shulou Source: shulou.com Published: 2022-06-01 11:36:08 10月03日 Update

Today, I would like to share with you the relevant knowledge of how to write the code of the java personnel information management system. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

To achieve additions, deletions, changes and searches.

The practice of getting started with java on Mini Program

1.Person class

Package p1; public class Person {/ / Person attributes private int num; private String name; private String sex; private int salary; public Person (int num, String name, String sex, int salary) {super (); this.num = num; this.name = name; this.sex = sex; this.salary = salary } / / A pair of Perosn operation methods public int getNum () {return num;} public void setNum (int num) {this.num = num;} public String getName () {return name;} public void setName (String name) {this.name = name;} public String getSex () {return sex } public void setSex (String sex) {this.sex = sex;} public int getSalary () {return salary;} public void setSalary (int salary) {this.salary = salary;}}

2.SysMenu class

Package p1; public class SysMenu {public static final String [] MENU = {"1. Employee Information Management, 2. Exit "}; public static final String [] OPERATION_MENU = {" 1. Add "," 2. Check "," 3. Modify "," 4. Delete "," 5. Return "}; public static void showMenu (String [] Menu) {for (int I = 0; I < Menu.length; iTunes +) System.out.print (Menu [I] +"\ t\ t "); System.out.println (); System.out.println ("-") }}

3.SysInfo class

Package p1; import java.util.ArrayList;import java.util.List; public class SysInfo {private static List informationList = new ArrayList (); / / get informationList public static List getList () {return informationList;}}

4.InformationService class

Package p1; import java.util.List; public class InformationService {private List informationList = SysInfo.getList (); / / get information list public List getList () {return informationList;} / / find information by number public Person getPersonByNum (final int num) {if (num < 1) {System.out.println ("numbering error"); return null } for (int I = 0; I < informationList.size (); iTunes +) {Person p = (Person) informationList.get (I); if (p.getNum () = = num) {System.out.println ("find success"); return p;}} System.out.println ("find failed") Return null;} / / View a single Person message public void showAPerson (Person p) {System.out.println ("No.\ t\ t name\ t\ t gender\ t\ t salary"); System.out.println (p.getNum () + "\ t\ t" + p.getName () + "\ t\ t" + p.getSex () + "\ t\ t" + p.getSalary ()) } / / show all Person public void showPerson () {System.out.println ("No.\ t\ t name\ t\ t gender\ t\ t salary"); List ps = getList (); for (int I = 0; I < ps.size (); iTunes +) {Person p = (Person) ps.get (I) System.out.println (p.getNum () + "\ t\ t" + p.getName () + "\ t\ t" + p.getSex () + "\ t\ t" + p.getSalary ());}} / / find information by name public Person getPersonByName (final String name) {if (name = = null) return null; for (int I = 0; I < informationList.size () Return null; +) {Person p = (Person) informationList.get (I); if (p.getName (). Equals (name)) {return p;}} return null;} / / check whether the object exists public boolean CheckExitByNum (int num) {for (int iTuno)

Tags: Input information system management knowledge articles management system object gender error person code valid success content name name salary selection different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Shulou Tech Info Apple Xiaomi