Java封装练习1-11,烦请老师检查和指正~
老师,为什么我在Eclipse里面运行没问题,但是在编程练习的页面上显示运行失败啊?
相关截图:
代码如下:
User类:
package imooc_object_users; public class User { private String name; private String password; public User() { } public User(String name, String password) { this.name = name; this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
UserManager类:
package imooc_object_users; public class UserManager { public String testUsers(User one, User two) { String str = null; if(one.getName().equals(two.getName())&&(one.getPassword().equals(two.getPassword()))) { str = "Consistent!"; }else { str = "Inonsistent!"; } return str; } }
TestUser类:
package imooc_object_users; public class TestUser { public static void main(String[] args) { User one = new User("Lucy", "123456"); User two = new User("Mike", "123456"); UserManager nm = new UserManager(); System.out.println("User 1 name: " + one.getName()); System.out.println("User 1 password: " + one.getPassword()); System.out.println("User 2 name: " + two.getName()); System.out.println("User 2 password: " + two.getPassword()); System.out.println("========================================"); String str = nm.testUsers(one, two); System.out.println(str); } }
39
收起
正在回答 回答被采纳积分+1
1回答
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星