初学java,自己用java写了一个简单的注册登录程序,没报错但有问题,希望能帮忙指点。

import java.util.Scanner;
class Yanzheng{
private String n;
private String p;
public void setNa(String na){
this.n = na;
}
public void setPa(String pa){
this.p = pa;
}
public String getNa(){
return n;
}
public String getPa(){
return p;
}
public boolean fun1(String name,String password){
if(name.equals(getNa()) && password.equals(getPa())){
return true;
}
else{
return false;
}
}
}

class Caozuo{
private String name;
private String password;
public String str;
public void setName(String name){
this.name = name;
}
public void setPassword(String password){
this.password = password;
}
public String getName(){
return name;
}
public String getPassword(){
return password;
}
Yanzheng yz = new Yanzheng();
public String fun2(){
if(yz.fun1(getName(),getPassword())){
str = "欢迎" + name + " 帅哥光临";
}else{
str = "用户名或密码输入错误";
}
return str;
}
public void fun3(){
Scanner in = new Scanner(System.in);
String na = in.next();
String pa = in.next();
Yanzheng yz = new Yanzheng();
yz.setNa(na);
yz.setPa(pa);
}
}

public class ZhuceXitong{
public static void main(String args[]){
System.out.println("开始注册,请输入注册名和密码!");
Scanner in = new Scanner(System.in);
Caozuo cz = new Caozuo();
cz.fun3();
System.out.println("注册成功,请登录!");
System.out.println("请输入用户名和密码!");
String name = in.next();
String password = in.next();
cz.setName(name);
cz.setPassword(password);
System.out.println(cz.fun2());
}
}

查看全部
fangxi01
[故事有你]
2015/02/09 06:50
  • java
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

5个回复