-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Hello, for student reasons I have looked for parts of your code where there may code smells and refactoring techniques can be applied.
In the CartItem and Cart classes you might get the stink of Inappropriate Intimacy because the getTotalPrice method is implemented in Cart but uses mostly information from CartItem
restaurant-management-system/src/restaurantsystem/model/Cart.java
Lines 36 to 43 in 34a5024
public double getTotalPrice() { | |
totalPrice = 0; | |
cartItems.forEach((cartItem) -> { | |
totalPrice += cartItem.getPrice(); | |
}); | |
return totalPrice; | |
} | |
To fix this bad smell you can apply the move method technique with it the getTotalPrice method you could work directly in CartItem with the price of the Item and the amount it has.
Here is an example of a possible implementation:


Metadata
Metadata
Assignees
Labels
No labels