- By Emmanuel Valverde
- ยท
- Posted Mar 5, 2024 12:05:53 PM
Morning Routine
As a forgetful person, I need to remember my morning routine. Because of this, I have created a program that, depending on the time of day, will tell..
We are building a shopping cart for an online grocery shop. The idea of this kata is to build the product in an iterative way.
Name | Cost | % Revenue | Price per unit | Tax | Final price |
Iceberg ๐ฅฌ | 1.55 โฌ | 15 % | 1,79 โฌ | Normal (21%) | 2.17 โฌ |
Tomato ๐ | 0.52 โฌ | 15 % | 0.60 โฌ | Normal (21%) | 0.73 โฌ |
Chicken ๐ | 1.34 โฌ | 12 % | 1.51 โฌ | Normal (21%) | 1.83 โฌ |
Bread ๐ | 0.71 โฌ | 12 % | 0.80 โฌ | First necessity (10%) | 0.88 โฌ |
Corn ๐ฝ | 1.21 โฌ | 12 % | 1.36 โฌ | First necessity (10%) | 1.50 โฌ |
Discounts code | Amount |
---|---|
PROMO_5 | 5% |
PROMO_10 | 10% |
As customer
I want to see my shipping cart
--------------------------------------------
| Product name | Price with VAT | Quantity |
| ----------- | -------------- | -------- |
|------------------------------------------|
| Promotion: |
--------------------------------------------
| Total productos: 0 |
| Total price: 0.00 โฌ |
--------------------------------------------
As customer
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Tomatoe ๐ to my shipping cart
I want to add Chicken ๐ to my shipping cart
I want to add Bread ๐ to my shipping cart
I want to add Corn ๐ฝ to my shipping cart
I want to see my shipping cart
--------------------------------------------
| Product name | Price with VAT | Quantity |
| ----------- | -------------- | -------- |
| Iceberg ๐ฅฌ | 2.17 โฌ | 1 |
| Tomatoe ๐
| 0.73 โฌ | 1 |
| Chicken ๐ | 1.83 โฌ | 1 |
| Bread ๐ | 0.88 โฌ | 1 |
| Corn ๐ฝ | 1.50 โฌ | 1 |
|------------------------------------------|
| Promotion: |
--------------------------------------------
| Total productos: 5 |
| Total price: 7.11 โฌ |
--------------------------------------------
As customer
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Tomatoe ๐ to my shipping cart
I want to add Chicken ๐ to my shipping cart
I want to add Bread ๐ to my shipping cart
I want to add Bread ๐ to my shipping cart
I want to add Corn ๐ฝ to my shipping cart
I want to see my shipping cart
--------------------------------------------
| Product name | Price with VAT | Quantity |
| ----------- | -------------- | -------- |
| Iceberg ๐ฅฌ | 2.17 โฌ | 3 |
| Tomatoe ๐
| 0.73 โฌ | 1 |
| Chicken ๐ | 1.83 โฌ | 1 |
| Bread ๐ | 0.88 โฌ | 2 |
| Corn ๐ฝ | 1.50 โฌ | 1 |
|------------------------------------------|
| Promotion: |
--------------------------------------------
| Total productos: 8 |
| Total price: 12.33 โฌ |
--------------------------------------------
As customer
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Iceberg ๐ฅฌ to my shipping cart
I want to add Tomatoe ๐ to my shipping cart
I want to add Chicken ๐ to my shipping cart
I want to add Bread ๐ to my shipping cart
I want to add Bread ๐ to my shipping cart
I want to add Corn ๐ฝ to my shipping cart
I want to apply my coupon code PROMO_5
I want to see my shipping cart
--------------------------------------------
| Product name | Price with VAT | Quantity |
| ----------- | -------------- | -------- |
| Iceberg ๐ฅฌ | 2.17 โฌ | 3 |
| Tomatoe ๐
| 0.73 โฌ | 1 |
| Chicken ๐ | 1.83 โฌ | 1 |
| Bread ๐ | 0.88 โฌ | 2 |
| Corn ๐ฝ | 1.50 โฌ | 1 |
|------------------------------------------|
| Promotion: 5% off with code PROMO_5 |
--------------------------------------------
| Total productos: 8 |
| Total price: 11.71 โฌ |
--------------------------------------------
You could change this API this is only for example purposes.
Approach 1 passing objects as arguments could be DTO
public interface ShoppingCart {
public void addItem(Product product);
public void deletItem(Product product);
public void applyDiscount(Discount discount)
public void printShoppingCart();
}
public interface ShoppingCart {
public void addItem(String productName);
public void deletItem(String productName);
public void applyDiscount(Double discount)
public void printShoppingCart();
}
Approach 3 passing primitives as arguments and returning a DTO
public interface ShoppingCart {
public void addItem(String productName);
public void deletItem(String productName);
public void applyDiscount(Double discount)
public ShoppingCartList getShoppingCart();
}
The graphic examples that you see on the kata are not there to be implemented if you don't want to, are there as a reference of how the kata works
As a forgetful person, I need to remember my morning routine. Because of this, I have created a program that, depending on the time of day, will tell..
Inspired by the creative works of Gawain Hewitt: https://gawainhewitt.co.uk/
Join our newsletter for expert tips and inspirational case studies
Join our newsletter for expert tips and inspirational case studies