}
}
else
{
// If the user is not a member of the group, then get the group
// name and check if it is a valid group
if (group != null)
{
if (group.length() > 0)
{
if (group.equals(„admin”))
{
System.out.println(„Admin”);
admin = true;
break;
}
else if (group.equals(„user”))
{
System.out.println(„User”);
user = true;
break;
}
else
{
System.out.println(„Invalid group name”);
}
}
}
}
}
else
{
System.out.println(„Invalid password”);
}
}
else
{
System.out.println(„User not found”);
}
}
}
}
/**
* Method to check the user’s credentials
* @param name
* @param password
* @return
*/
private boolean checkCredentials(String name, String password)
{
boolean valid = false;
if (name.equals(„admin”) && password.equals(„admin”))
{
valid = true;
}
else if (name.equals(„user”) && password.equals(„user”))
{
valid = true;
}
else
{
valid = false;
}
return valid;
}
/**
* Method to show the menu for the admin user
*/
private void adminMenu()
{
System.out.println(„1. Add new book”);
System.out.println(„2. Add new member”);
System.out.println(„3. Search for a book”);
System.out.println(„4. Search for a member”);
System.out.println(„5. Display all books”);
System.out.println(„6. Display all members”);
System.out.println(„7. Exit”);
}
/**
* Method to show the menu for the normal user
*/
private void userMenu()
{
System.out.println(„1. Search for a book”);
System.out.println(„2. Search for a member”);
System.out.println(„3. Exit”);
}
/**
* Method to add a new book to the library
*/
private void addBook()
{
System.out.println(„Enter the title of the book:”);
String title = input.nextLine();
System.out.println(„Enter the author of the book:”);
Hofmolkerei Dehlwes28865 Lilienthal
