You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On page 518, the if statement in the method PagingProducts() is used without braces:
if (key == ConsoleKey.LeftArrow)
if (currentPage == 0)
currentPage = totalPages;
else
currentPage--;
else if (key == ConsoleKey.RightArrow)
if (currentPage == totalPages)
currentPage = 0;
else
currentPage++;
else
break; // out of the while loop.
I think it should be written with braces:
if (key == ConsoleKey.LeftArrow)
{
if (currentPage == 0)
{
currentPage = totalPages;
}
else
{
currentPage--;
}
}
else if (key == ConsoleKey.RightArrow)
{
if (currentPage == totalPages)
{
currentPage = 0;
}
else
{
currentPage++;
}
}
else
{
break; // out of the while loop.
}
Or in the more concise form:
if (key == ConsoleKey.LeftArrow)
{
currentPage = (currentPage == 0) ? totalPages : currentPage - 1;
}
else if (key == ConsoleKey.RightArrow)
{
currentPage = (currentPage == totalPages) ? 0 : currentPage + 1;
}
else
{
break; // out of the while loop.
}
The text was updated successfully, but these errors were encountered:
MAS-OUD
changed the title
if statement without braces in the PagingProducts() method on page 518
if statement used without braces in the PagingProducts() method on page 518
May 4, 2023
On page 518, the if statement in the method
PagingProducts()
is used without braces:I think it should be written with braces:
Or in the more concise form:
The text was updated successfully, but these errors were encountered: