title: How do I check which java instance method has been called to apply appropriate discount to the property?
body: <p>So, basically I have a Funpark class which has 3 activities. If user enrolls in 2 activities, then I want to apply 10% discount on totalPrice and if they apply to all 3 activities, I want to give 20% discount on totalPrice.</p>
  <p>Here is my code for FunPark class:</p>
  <pre><code>public class FunPark {
      private final int climbWallPrice = 10;
      private final int trampoliningPrice = 12;
      private final int waterSlidesPrice = 15;
  
      public float getTotalPrice() {
          return totalPrice;
      }
  
      private float totalPrice = 0;
  
      private float applyDiscountTo(float applyTo, int discountInPercent) {
  
          float discount = (float) discountInPercent / 100;
          float discountValue = applyTo * discount;
  
          float discountedPrice = applyTo - discountValue;
  
          return discountedPrice;
      }
  
      public void climbWall() {
          if(totalPrice == trampoliningPrice || totalPrice == waterSlidesPrice) {
              totalPrice += climbWallPrice;
              totalPrice = applyDiscountTo(totalPrice, 10);
          }
  
          else if(totalPrice == trampoliningPrice + waterSlidesPrice) {
              totalPrice += climbWallPrice;
              totalPrice = applyDiscountTo(totalPrice, 20);
          }
  
          else {
              totalPrice = climbWallPrice;
          }
      }
  
      public void trampoline() {
          if(totalPrice == climbWallPrice || totalPrice == waterSlidesPrice) {
              totalPrice += trampoliningPrice;
              totalPrice = applyDiscountTo(totalPrice, 10);
          }
  
          else if(totalPrice == climbWallPrice + waterSlidesPrice) {
              totalPrice += trampoliningPrice;
              totalPrice = applyDiscountTo(totalPrice, 20);
          }
  
          else {
              totalPrice = trampoliningPrice;
          }
      }
  
  
  
      public void waterSlide() {
          if(totalPrice == climbWallPrice || totalPrice == trampoliningPrice) {
              totalPrice += waterSlidesPrice;
              totalPrice = applyDiscountTo(totalPrice, 10);
          }
  
          else if(totalPrice == climbWallPrice + trampoliningPrice) {
              totalPrice += waterSlidesPrice;
              totalPrice = applyDiscountTo(totalPrice, 20);
          }
  
          else {
              totalPrice = waterSlidesPrice;
          }
      }
  
  }
  </code></pre>
  <p>The output I get is <code>15.0</code></p>
  <p>But, my expected result (in this case) is <code>37.6</code> (because of course the sum price for all three activities - 20% discount is <code>29.6</code></p>
  <p>Here is my calling code in the main class btw:</p>
  <pre><code>public class Main {
      public static void main(String[] args) {
          System.out.println(&quot;Hello world!&quot;);
  
          FunPark park = new FunPark();
  
          park.trampoline();
          park.climbWall();
          park.waterSlide();
  
          System.out.println(park.getTotalPrice());
      }
  }
  </code></pre>
  <p>So, could anyone please guide me in a direction on how should I go on about achieving the result? Thanks.</p>