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
public void ShowBooks()
{
for (int i = 0; i < books.Count; i++)
{
Console.WriteLine("Title: " + books[i].title + ", Author: " + books[i].author);
}
}
public void FindBook(string t)
{
for (int i = 0; i < books.Count; i++)
{
if (books[i].title == t)
{
Console.WriteLine("Found: " + books[i].title + " by " + books[i].author);
return;
}
}
Console.WriteLine("Book not found");
}
Description:
Both methods ShowBooks() and FindBook() have almost the same loop for iterating books.
This violates the principle of DRY, because the data access logic is repeated.
The text was updated successfully, but these errors were encountered:
Code:
Description:
Both methods ShowBooks() and FindBook() have almost the same loop for iterating books.
This violates the principle of DRY, because the data access logic is repeated.
The text was updated successfully, but these errors were encountered: