Created
August 24, 2018 11:30
-
-
Save videlalvaro/7b60e3cb68a07392e5913a42787b5f9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.store.user; | |
/** | |
* Implements a user for our store. | |
*/ | |
public class User { | |
private String name; | |
public User(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return this.name; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (obj == null) return false; | |
if (!(obj instanceof User)) | |
return false; | |
if (obj == this) | |
return true; | |
return this.getName() == ((User) obj).getName(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment