Advertisement
Guest User

Puppy.java

a guest
Apr 27th, 2015
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. public class Puppy {
  2.     private int biscuitSize;
  3.     private int happiness = 0;
  4.     String mood = "E0";
  5.     public Puppy(int biscuitSize) {
  6.         this.biscuitSize = biscuitSize;
  7.     }
  8.  
  9.     public int getBiscuitSize() {
  10.         return biscuitSize;
  11.     }
  12.  
  13.     public void setHappiness(int a, int b) {
  14.         if (biscuitSize > a) {
  15.             happiness++;
  16.         } else if (biscuitSize < a) {
  17.             happiness--;
  18.         }
  19.  
  20.         if (biscuitSize > b) {
  21.             happiness++;
  22.         } else if (biscuitSize < b) {
  23.             happiness--;
  24.         }
  25.         if (happiness > 1) {
  26.             setMood(":)");
  27.         } else if (happiness < -1) {
  28.             setMood(":(");
  29.         } else if (happiness < 2 && happiness > -2) {
  30.             setMood(":|");
  31.         }
  32.     }
  33.     public void setHappiness(int a) {
  34.         if (biscuitSize > a) {
  35.             happiness++;
  36.         } else if (biscuitSize < a) {
  37.             happiness--;
  38.         }
  39.         if (happiness == 1) {
  40.             setMood(":)");
  41.         } else if (happiness == -1) {
  42.             setMood(":(");
  43.         } else {
  44.             setMood(":|");
  45.         }
  46.     }
  47.  
  48.     public void setMood(String mood) {
  49.         this.mood = mood;
  50.     }
  51.  
  52.     public String getMood() {
  53.         return mood;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement