Verification of Java Login Registration

Source: Internet
Author: User

Import java.util.ArrayList;
Import java.util.List;
Import Java.util.Scanner;
Class person{
String Zhanhao;
String Mima;
Public person (String name,string ID) {

This.zhanhao=name;
This.mima=id;
}
@Override
Public String toString () {
TODO auto-generated Method Stub
Return "account =" +this.zhanhao+ "password =" +this.mima;
}
@Override
public boolean equals (Object obj) {
TODO auto-generated Method Stub
if (obj instanceof person) {
Person P = (person) obj;
if (P.zhanhao==this.zhanhao&&p.mima==this.mima) {
return true;
}else {
return false;
}
}else {
return false;
}




}
@Override
public int hashcode () {
TODO auto-generated Method Stub
return This.zhanhao.hashCode ();
}


}



Class zuce{
Static ArrayList shuju=new ArrayList ();
public void Paly () {

SYSTEM.OUT.PRINTLN ("Please select function: Register (A) login (B) exit system (Q)");
Scanner SCA = new Scanner (system.in);
String str = Sca.next ();
if (Str.equalsignorecase ("a")) {

Yi ();

}else if (str.equalsignorecase ("B")) {

ER ();

}else if (str.equalsignorecase ("C")) {

SYSTEM.OUT.PRINTLN ("Thank you for your use");

}else {

SYSTEM.OUT.PRINTLN ("Input error please restart");

}
}
public void Yi () {

System.out.println ("Please enter the registered account:");

Scanner SCA = new Scanner (system.in);

String str = Sca.next ();
for (int i = 0; i < shuju.size (); i++) {
Person P = (person) shuju.get (i);
if (P.zhanhao.equalsignorecase (str)) {
System.out.println ("The account you entered already exists, please re-enter");
Yi ();
Break
}
}

System.out.println ("Please enter password:");

Scanner SCA1 = new Scanner (system.in);

String sum = Sca1.next ();
Person P=new person (str, sum);
Shuju.add (P);

System.out.println (Shuju);
Paly ();

}
public void er () {
System.out.println ("Please enter your account:");
Scanner SCA = new Scanner (system.in);
String str = Sca.next ();
System.out.println ("Please enter password:");
Scanner SCA1 = new Scanner (system.in);
String sum = Sca1.next ();
Person P=new person (str, sum);
for (int i = 0; i < shuju.size (); i++) {
Person p1= (person) shuju.get (i);

if (P1.zhanhao.equals (P.zhanhao) &&p1.mima.equals (P.mima)) {

SYSTEM.OUT.PRINTLN ("Login Successful");
System.out.println ("User name:" +p.zhanhao);
Paly ();
}else {
SYSTEM.OUT.PRINTLN ("Login Failed");
Paly ();

}
}





}

}
public class Work2 {

/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
Zuce zz=new zuce ();
Zz.paly ();

}

}

Verification of Java Login Registration

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.