Skip to content

Commit 1d35714

Browse files
committed
Clarify order of operations in totalPrice calculation
The code change in the `HandleBurgersAsync` method of the `CafeController` class modifies the calculation of the `totalPrice` variable. The original calculation `burgers * burgerPrice + (drink ? drinkPrice : 0)` has been updated to include parentheses around the burger price calculation: `(burgers * burgerPrice) + (drink ? drinkPrice : 0)`. This change ensures that the multiplication operation is explicitly prioritized over the addition operation, although the original code would have worked correctly due to operator precedence rules. This change improves code readability and reduces potential misunderstandings regarding the intended calculation.
1 parent fbff5de commit 1d35714

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Sources/TelegramBot.ConsoleTest/Controllers/CafeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task<IActionResult> HandleBurgersAsync(int burgers, bool drink)
3030
const int burgerPrice = 5;
3131
const int drinkPrice = 2;
3232
int cookTime = Random.Shared.Next(18, 35);
33-
int totalPrice = burgers * burgerPrice + (drink ? drinkPrice : 0);
33+
int totalPrice = (burgers * burgerPrice) + (drink ? drinkPrice : 0);
3434

3535
string text = "🍽🍽🍽🍽🍽🍽🍽🍽🍽🍽🍽🍽\n" +
3636
"Vadim's Burgers got your order!\n\n" +

0 commit comments

Comments
 (0)