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.
}
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: