-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryManager.cs
More file actions
78 lines (68 loc) · 2.53 KB
/
Copy pathLibraryManager.cs
File metadata and controls
78 lines (68 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
public class LibraryManager
{
private readonly Library _library; //composition of Library class, LibraryManager cannot exist without it
private readonly MenuManager _menuManager;
public LibraryManager(Library library)
{
_library = library;
_menuManager = new MenuManager();
}
public int ManageLibrary()
{
int option;
do
{
option = _menuManager.DisplayLibraryMenu();
switch(option)
{
case 1: LendBookToMember();
break;
case 2: ReturnBookFromMember();
break;
case 3: ViewBorrowedBooksPerMember();
break;
case 4: Console.WriteLine($"Total Number of Books: {_library.GetTotalBooksCount()}");
break;
case 5: Console.WriteLine($"Total Number of Members: {_library.GetTotalMembersCount()}");
break;
case 6: Console.WriteLine();
Console.WriteLine("Exiting Library Management...");
break;
case 7: Console.WriteLine();
Console.WriteLine($"Exiting the system... Goodbye {GlobalVariables.Name}!");
break;
default:Console.WriteLine("Invalid option. Please try again.");
break;
}
}while(option != 6 && option != 7);
return option;
}
public void LendBookToMember()
{
Console.WriteLine();
Console.Write("Please enter the Book ID: ");
int bookId = int.Parse(Console.ReadLine());
Console.Write("Please enter the Member ID: ");
int memberId = int.Parse(Console.ReadLine());
Console.WriteLine("Lending book to the member......");
_library.LendBook(bookId, memberId);
}
public void ReturnBookFromMember()
{
Console.WriteLine();
Console.Write("Please enter the Book ID: ");
int bookId = int.Parse(Console.ReadLine());
Console.Write("Please enter the Member ID: ");
int memberId = int.Parse(Console.ReadLine());
Console.WriteLine("Returning book from the member......");
_library.ReceiveBook(bookId, memberId);
}
public void ViewBorrowedBooksPerMember()
{
foreach(var member in _library.GetMembers())
{
Console.WriteLine($"Member: {member.GetName()},\nBorrowed Books: ");
member.DisplayBorrowedBooks();
}
}
}