Learn Java from the beginning of the entrance Guard Management (ii)

Source: Internet
Author: User

This system contains four pieces, the first block is the personnel management, managers assigned three people have "ABC" permission, respectively, management of leave application, leave approval, guard registration management. At the same time does not belong to the company's internal personnel, such as other company's personnel if the thought of the company's visit, is also the first through the "ABC" authority of the three people to write a visit application, visit the examination and approval, visit the Guard registration management.

The steps are as follows:

Because there are a lot of the same methods, and the same properties, so I first set up two interfaces so that the next method class and the attribute class both implement both interfaces, thus reducing the coupling degree.

Learn Java from the beginning of the gate Management (a) it contains the interface I built, the interface of the method and manager to give "ABC" permission and to remove the permissions, I wrote the default three account and password (permission a: Account 1001 Password: 1314 rights B: Account 1002 Password: 1314 rights c: Account 1003 Password: 1314 ), you can re-establish the "new" through the management interface, or "dismiss the elderly."

This time I first show you the main function: The main function contains the manager login account: admin password: admin. As well as various aspects of login after the different permissions to invoke a different management interface:


1. Main function, enter the mouth. Only the manager management interface has been published earlier, so you can only enter Ev.main (); Other methods need to be updated. Code interface class with permission B added later

The code is:

Package Com.jereh.discrepancy;import Java.util.scanner;public class Test {gorequestview GBV = new Gorequestview (); Guestsview GV = new Guestsview (); Employeer emp = new Employeer (); Employeerbiz EMPB = new Employeerbiz (); Employeerview ev = new Employeerview (); Examineview Exa = new Examineview (); Manegerview mv = new Manegerview (); Scanner input = new Scanner (system.in);p ublic void judge () {System.out.println ("##################################### ################"); System.out.println ("################ #1. Application for out-of-office 2. ################"); System.out.print ("################ #请输入你要选择的选项编号:"); int i = Input.nextint (); if (i==1) {Gbv.gomain ();} else if (i==2) {Gv.guestsmain ();} ElseSystem.out.println ("@@@@@@@======= does not have this option! [email protected]@@@@@ ");} public void Check () {empb.as (); System.out.print ("\[email protected]@@@ 请 Enter your account:"); String in = Input.next (); System.out.print ("\[email protected]@@@ 请 Enter Password:"); String pwd = Input.next (), EMP = Empb.deng (in, PWD), if (emp==null) {System.out.println ("The account password you entered does not match!" ######");} Else{if (Emp.getlev (). Equals ("T")) {Ev.main ();} else if (Emp.getlev (). Equals ("A")) {judge ();} else if (Emp.getlev (). Equals ("B")) {Exa.examinemain ();} else if (Emp.getlev (). Equals ("C")) {Mv.managermain ();}}} public static void Main (string[] args) {test test = new Test (); Test.check ();}}
2. Special class: It contains a special method----This method is to translate the five states that I originally defined into text to cover the status represented by the number: 0--representative to apply for a 2--representative to approve the refusal of 3--representative out of the Guard 4--representative return. Mainly users can not understand what we write 01234, so for the sake of convenience I wrote this method, this method and other classes are not directly related, so I wrote a separate class:

The code is:

Package Com.jereh.discrepancy;public class Replenish {public String tran (int i) {//conversion: Convert state 0,1,2,3 to text and return if (i==0) { Return "Apply for ing";} else if (i==1) {return ' approval Pass ';} else if (i==2) {return "Rejected";} else if (i==3) {return ' over security ';} else if (i==4) {return "has been checked";} Elsereturn null;}}

3. Approval class: That is, after the application is submitted, the person of authority B approves the application, the application status is 1, and the application is dismissed as 2. Because in the gatekeeper's interface, to display all approved personnel information, and then enter the number, if the number exists, you can go through the doorman:

The code is:

Package Com.jereh.discrepancy;import Java.util.scanner;public class Examineview {Scanner input = new Scanner (system.in) ; guestsbiz GB = new guestsbiz (); Gorequestbiz gr = new gorequestbiz ();p ublic void AddView () {while (true) {System.out.println ("*************** Approval management ****** ****************"); System.out.println ("\ t employee \t\t employee name \t\t out of office \t\t out time \t\t" + "return time \t\t status \t\t"); Gr.show0 (); System.out.println ("======================================================="); System.out.print ("$$$$$$$$======== 1. Approval 2. Dismiss 3. Exit: "); int n = input.nextint (); System.out.print ("@@@@@@@@======== Please enter the option number you want to operate:"), int num = Input.nextint (), if (n==3) {system.exit (0);} else if (Gr.change (num, N) && (n==1| | n==2) {System.out.println ("************* Operation succeeded! Congratulations to the leader and a black horse! *****");} else System.out.println ("+++++++++your mother flew ++++++++++");}} public void ShowView () {while (true) {System.out.println ("*************** Approval Management **********************"); System.out.println ("\ t visit number \t\t visitor name \t\t Visit \t\t Visitor's company \ T" + "visit time \t\t status \t\t"); Gb.show0 (); System.out.println ("======================================================="); System.out.print ("$$$$$$$$======== 1. Approval 2. Dismiss 3. Exit: "); int n = input.nextint (); System.out.print ("@@@@@@@@======== Please enter the option number you want to operate:"), int num = Input.nextint (), if (n==3) {system.exit (0);} else if (Gb.change (num, N) && (n==1| | n==2) {System.out.println ("************* Operation succeeded! Congratulations to the leader and a black horse! *****");} else System.out.println ("+++++++++your mother flew ++++++++++");}} public void Examinemain () {while (true) {System.out.println ("&&&&&&&&&& &&&&&&&&&& Application Approval &&&&&&&&&&& &&&&&&&&&&&& "); System.out.println ("$$$$$$$$$$$$===1. Application for Approval ===$$$$$$$$$$$$"); System.out.println ("$$$$$$$$$$$$===2. Request for approval ===$$$$$$$$$$$$"); System.out.println ("$$$$$$$$$$$$====================$$$$$$$$$$$$"); System.out.print ("Enter the option number you want to operate:"); int in = Input.nextint (); if (in==1) {AddView ();} else if (in==2){ShowView ();} ElseSystem.out.println ("*********=== Pro, no special service you want ===*********");}}

This will be written this time, not to be continued ....



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Learn Java from the beginning of the entrance Guard Management (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.