hazer_hazer

Untitled

Nov 10th, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Objects;
  2.  
  3. public class Phrase{
  4.     private Mood mood;
  5.     private String text;
  6.  
  7.     public Phrase(Mood mood, String text){
  8.         this.mood = mood;
  9.         this.text = text;
  10.  
  11.         Logger.log("[Phrase] New Phrase was created with mood", mood.name(), "and text:", text);
  12.     }
  13.    
  14.     public Mood getMood(){
  15.         return mood;
  16.     }
  17.     public String getText(){
  18.         return text;
  19.     }
  20.    
  21.     @Override
  22.     public String toString(){
  23.         return "Phrase {\n\tText: " + text + "\n\tMood: " + mood.toString() + "\n}";
  24.     }
  25.  
  26.     @Override
  27.     public boolean equals(Object o) {
  28.         if (this == o) return true;
  29.         if (!(o instanceof Phrase)) return false;
  30.         Phrase that = (Phrase) o;
  31.         return mood.equals(that.mood) && text.equals(that.text);
  32.     }
  33.  
  34.     @Override
  35.     public int hashCode() {
  36.         return Objects.hash(mood, text);
  37.     }
  38. }
Add Comment
Please, Sign In to add comment