package com.flipper83.katapotter;

import java.util.List;

public class BasketCalculator {
  private static final int BOOK_PRICE = 8;
  private static final float BOOK_DISCOUNT = 0.95f;

  public float calculatePrice(List<String> books) {

    NormalizeBasket normalizeBasket = new NormalizeBasket();
    normalizeBasket.addBooks(books);

    float amount = 0.0f;
    for (SetCollection collection : normalizeBasket.getCollections()) {
      int numBooks = collection.numBooks();
      if (numBooks > 1) {
        amount += BOOK_PRICE * BOOK_DISCOUNT * numBooks;
      } else {
        amount += BOOK_PRICE * numBooks;
      }
    }
    return amount;
  }
}

@@ -178,9 +178,9 @@
 = 0.
-9
+0
 5f;%0A
@@ -483,30 +483,54 @@
     
-if (numBooks %3E 1) %7B%0A  
+float discount = calculateDiscount(numBooks);%0A
     
@@ -554,29 +554,24 @@
 PRICE * 
-BOOK_DISCOUNT
+discount
  * numBo
@@ -583,91 +583,134 @@
     
-  %7D else %7B%0A        amount += BOOK_PRICE * numBooks;%0A      %7D%0A    %7D%0A    return amount
+%7D%0A    return amount;%0A  %7D%0A%0A  private float calculateDiscount(int numBooks) %7B%0A    return 1.0f - ((numBooks - 1) * BOOK_DISCOUNT)
 ;%0A  

Add code for check different discounts for different number of books.