atanasovetr

LutenicaJar

Oct 25th, 2020
913
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class LutenicaJar {
  2.     double pepperPercentage;
  3.     double tomatoPercentage;
  4.     double jarCapacity;
  5.     double salt;
  6.     double season;
  7.     boolean transparentJar;
  8.     boolean haveCarrot;
  9.     boolean isDone;
  10.  
  11.  
  12.     public LutenicaJar(){
  13.         this.pepperPercentage = 0;
  14.         this.tomatoPercentage = 0;
  15.         this.jarCapacity = 200;
  16.         this.salt = 0;
  17.         this.season = 0;
  18.         this.transparentJar = true;
  19.         this.isDone = false;
  20.         this.haveCarrot = false;
  21.  
  22.         System.out.println("I like your idea to create some Lutenica! :)");
  23.     }
  24.  
  25.     void cooking(){
  26.         isDone = true;
  27.         System.out.println("You just cooked your Lutenica!!!");
  28.     }
  29.     void addingPepper(double pepper){
  30.         this.pepperPercentage = (pepper/this.jarCapacity) * 100;
  31.         System.out.println("Isn't that too much peppers?");
  32.     }
  33.     void addingTomato(double tomato){
  34.         this.tomatoPercentage = (tomato/this.jarCapacity) * 100;
  35.         System.out.println("That's a nice amount of Tomatoes!");
  36.     }
  37.  
  38.     void addingSalt(double moreSalt){
  39.         this.salt += moreSalt;
  40.         System.out.println("It wasn't salty enough, righht?");
  41.     }
  42.     void info(){
  43.         System.out.println();
  44.         System.out.println(("In your jar you have"+ String.format("%.2f", this.pepperPercentage) + "% of pepper and "+ String.format("%.2f", this.tomatoPercentage)+  "% of tomatoes."));
  45.         if (this.salt >= this.jarCapacity/20) {
  46.             System.out.println(String.format("You have %.1fg of salt. That's too much for your Lutenica!", this.salt));
  47.         }
  48.         else{
  49.             System.out.println(String.format("You have %.1fg of salt. That much is good for your Lutenica!", this.salt));
  50.  
  51.         }
  52.         if (this.transparentJar){
  53.             System.out.println("Congratulations! You can see your Lutenica through the jar!");
  54.         }
  55.         else{
  56.             System.out.println("Don't worry. You can always open it and see it from the top! :)");
  57.         }
  58.         if (this.haveCarrot){
  59.             System.out.println("Nice decision to put some carrot! ;)");
  60.         }
  61.         else{
  62.             System.out.println("You don't have carrot. Everybody has a different taste!");
  63.         }
  64.         if (this.isDone){
  65.             System.out.println("You have ready-to-eat Lutenica. :)");
  66.         }
  67.         else{
  68.             System.out.println("You have to cook that beauty.");
  69.         }
  70.         System.out.printf("Your lutenica is from season %s", this.season);
  71.         if (this.season < 2018){
  72.             System.out.print("It's a bit old but I hope it's still delicious.");
  73.         }
  74.         else{
  75.             System.out.print("It's fresh. Go for it!!!");
  76.         }
  77.     }
  78. }
  79.  
RAW Paste Data