Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- public class Phrase{
- private Mood mood;
- private String text;
- public Phrase(Mood mood, String text){
- this.mood = mood;
- this.text = text;
- Logger.log("[Phrase] New Phrase was created with mood", mood.name(), "and text:", text);
- }
- public Mood getMood(){
- return mood;
- }
- public String getText(){
- return text;
- }
- @Override
- public String toString(){
- return "Phrase {\n\tText: " + text + "\n\tMood: " + mood.toString() + "\n}";
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Phrase)) return false;
- Phrase that = (Phrase) o;
- return mood.equals(that.mood) && text.equals(that.text);
- }
- @Override
- public int hashCode() {
- return Objects.hash(mood, text);
- }
- }
Add Comment
Please, Sign In to add comment