请帮我批改一下这次的作业

来源:1-13 编程练习

M灬spirit

2019-09-26 08:44:51

public class UserManager {
    // 用户信息验证的方法
    public String checkUser(User one, User two) {
       // 判断用户名和密码是否为空,是否一致
    	if(one.getName().equals(two.getName()) && one.getNum().equals(two.getNum()))
    		return "用户名和名字一致";
    	else
    		return "用户名或名字不一致";
    }
}

public class Test {

    // 测试方法

public static void main(String[] args) {

     //实例化对象,调用相关方法实现运行效果

User one=new User("Lucy","123456");

User two=new User("Mike","123456");

System.out.println(one);

System.out.println(two);

System.out.println("==============");

System.out.println(new UserManager().checkUser(one, two));

}


}

public class User {

    //定义属性用户名、密码

private String name;

private String num;

//构造方法

public User(String name,String num) {

this.setName(name);

this.setNum(num);

}

//生成getter和setter方法

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getNum() {

return num;

}

public void setNum(String num) {

this.num = num;

}

//重写

public String toString() {

return "用户名:"+this.getName()+"/n密码:"+this.getNum();

}

}


写回答

1回答

好帮手慕小尤

2019-09-26

同学你好,逻辑正确!继续努力!如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

0

0 学习 · 11489 问题

查看课程