Simple registration login system

代码:(三部分:Sx.java -> Student_control.java -> startl.java)*****************************Sx.java****************************
package com.qsy.student.sx;
public class Sx {
    private int ID;
    private String name;
    private int age;
    private String sex;
    private String school;
    public int getID() {
        return ID;
    }
    public void setID(int ID) {
        this.ID=ID;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name=name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age=age;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex=sex;
    }
    public String getSchool() {
        return school;
    }
    public void setSchool(String school) {
        this.school=school;
    }
}
************************start.java*******************************
package com.qsy.student.start;

import com.qsy.student.control.Student_control;

import java.util.Scanner;

public class Start {
    public static void main(String[] args) {
        Student_control iss=new Student_control();
        System.out.println("Student Information Management System -------- ---------" ); 
        System.out.println ( . "---------- ----- 1 Registration ------- " ); 
        System.out.println ( ." ---------- 2 Log ------------ " ); 
        System.out.println ( . "exit ----------3 -----------------------" );
         new new the Start () STA ();. 
    } 
    public  void STA () { 
        Student_control ISS = new new Student_control ();
         the while ( to true ) { 
        System.out.println ( "You want to do what ..." ); 
        Scanner INS = new new Scanner (System.in); 
        NNT:
        the while ( to true ) {
         int NO = ins.nextInt ();
             IF (== NO. 1 ) { 
                System.out.println ( "Registered the Y / N" ); 
                String FEN = ins.next ();
                 the while ( "the Y" .equals (FEN)) { 
                    iss.shuzu (); 
                    System.out.println ( "You also need to add student information do the Y-/ N?" ); 
                    FEN = ins.next (); 
                } 

               BREAK ; 
            } the else  IF (NO == 2 ) { 
                System.out.println ( "Login" ); 
                iss.login (); 
                BREAK ; 
            } the else  IF (NO == 3 ) { 
                System.out.println ( "Thank use ... I wish you a happy life!" );
                 BREAK ; 
            } the else { 
                System.out.println ( "Without this option, please re-select ..." ); 
            } 
        } 
        } 
    } 
}
 ********************* Student_control.java ********************** ***
 Package Penalty for com.qsy.student.control;
 Import com.qsy.student.sx.Sx;
Import java.util.Scanner;
 public  class Student_control { 
    to Sx ISX = new new to Sx ();
     Private  int I; 
    to Sx Student [] = new new to Sx [10 ];
     // to Sx cfstudent [] = new new to Sx [10]; 
    Scanner INS = new new Scanner (the System.in);
     public  static  void main (String [] args) { 
    } 
    // array of objects Log Register 
    public to Sx [] shuzu () { 

        // Student [I] to Sx new new = (. 1, "NN", . 3, "NV", "sss");
         // int i = 0; // each call will be 1 i 
        Student [i] = new new to Sx ();

        System.out.println("请输入ID:");
        student[i].setID(ins.nextInt());
        //System.out.println("ID为:");

        System.out.println("请输入name:");
        student[i].setName(ins.next());
        //System.out.println("name为:");

        System.out.println("请输入age:");
        student[i].setAge(ins.nextInt());
        //System.out.println("age为:");

        System.out.println("请输入sex:");
        student[i].setSex(ins.next());
        //System.out.println("sex为:");

        System.out.println("Please enter the School: " ); 
        Student [I] .setSchool (ins.next ()); 
        // System.out.println ( "School of:"); 

        I ++ ;
         return  the this .student; 
    } 
    public  void Login () { 

        Scanner INS = new new Scanner (the System.in); 
        OUT: 
        the while ( to true ) {
             // Student [0] = new new to Sx (. 1, "NN",. 3, "NV", "sss"); 

            the System.out. println ( "Please enter the desired query name:" ); 
            String rr = ins.next (); 
            System.out.println ( "Please enter your password:");
            int mm=ins.nextInt();
            if (rr!=null){
                //boolean yes=false;
                for (int j=0; j <this.student.length ; j++) {
                    if (this.student[j]!=null){
                        if (rr.equals(this.student[j].getName())&& mm==123){
                            System.out.println("祝贺你!登录成功");
                            //yes=true;
                            break OUT;
                        }
                    }
                    } 
                        System.out.println ( "no such person" ); 
            } 
            the else { 
                System.out.println ( "what operations should be performed under Y, not N?" ); 
                String AA = ins.next ();
                 IF ( "the Y" .equals (AA)) 
                {System.out.println ( "Please re-enter your name and password" );}
                 the else  IF ( "N" .equals (AA)) {
                     BREAK OUT; 
                } the else { 
                    the System. out.println ( "input error" );
                    break OUT;
                }
            }
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/qsy0021/p/11291128.html