This short and simple Kata should be performed using Test Driven Development (TDD).
There is a series of books about software development that have been read by a lot of developers who want to improve their development skills. Let’s say an editor, in a gesture of immense generosity to mankind (and to increase sales as well), is willing to set up a pricing model where you can get discounts when you buy these books. The available books are :
The rules are described below :
One copy of the five books costs 50 EUR.
Developers seeking to deliver quality products are queueing up with shopping baskets overflowing with these books. Your mission is to write a piece of code to calculate the price of any conceivable shopping basket.
For example, how much does this basket of books cost?
Answer :
(4 * 50 EUR) - 20% [first book, second book, third book, fourth book]
(4 * 50 EUR) - 20% [first book, second book, third book, fifth book]
= 160 EUR + 160 EUR
= 320 EUR (knowledge is priceless but has a cost)
Clean Code - TDD : click here
IMPORTANT: Implement the requirements focusing on writing the best code you can produce.