public class userManager {
public String checkUser(User one,User two) {
String str=null;
//判断用户名是否为空
if(one.getUserName().equals(two.getUserName())){
System.out.println("用户名为空");
}
else if (!(one.getUserName().equals(two.getUserName())))
{ //one.getUserName().equals(two.getUserName()
//类似等价
System.out.println("用户名不一致");
}
// 判断密码是否为空,是否一致
if(one.getPassword()==(two.getPassword())) {
System.out.println("密码为空");
}
else if(!(one.getPassword()==(two.getPassword()))){
System.out.println("密码不一致");
}
return str;
}
}
class User{
//定义属性用户名、密码
private String username;
private int password;
public String getUserName() {
return username;
}
public void setUserName(String username) {
this.username = username;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;}
public void print() {
System.out.println("用户名"+getUserName());
System.out.println("密码"+getPassword());
}
}
class Test{
// 测试方法
public static void main(String[] args) {
//实例化对象,调用相关方法实现运行效果
User one=new User();
User two=new User();
one.setUserName("Lucy");
one.setPassword(123456);
one.print();
two.setUserName("Mike");
two.setPassword(123456);
two.print();
System.out.println("=================");
userManager aaa=new userManager ();
System.out.println(aaa.checkUser( one, two));
}
}
慕侠9004270
慕用0363343
qq_双子星深蓝_0
慕的地6079101
慕哥5285776
你不是最丑的
mr小卓X
你不是最丑的
相关分类