-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooksManager.cs
More file actions
79 lines (69 loc) · 2.44 KB
/
Copy pathBooksManager.cs
File metadata and controls
79 lines (69 loc) · 2.44 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
79
public class BooksManager
{
private readonly Library _library;
private readonly MenuManager _menuManager;
public BooksManager(Library library)
{
_library = library;
_menuManager = new MenuManager();
}
public int ManageBooks()
{
int option;
do
{
option = _menuManager.DisplayBookMenu();
switch (option)
{
case 1: AddBook();
break;
case 2: RemoveBook();
break;
case 3: Console.WriteLine();
_library.ShowAvailableBooks();
break;
case 4: Console.WriteLine();
_library.ShowAllBooks();
break;
case 5: Console.WriteLine();
Console.WriteLine($"Exiting Book Management...");
break;
case 6: Console.WriteLine();
Console.WriteLine($"Exiting the system... Goodbye {GlobalVariables.Name}!");
break;
default:Console.WriteLine();
Console.WriteLine("Invalid option. Please try again.");
break;
}
}while(option != 5 && option != 6);
return option;
}
public void AddBook()
{
Console.WriteLine();
Console.WriteLine("Please enter below details to add a book:");
//Console.Write("Book ID: ");
//int bookId = int.Parse(Console.ReadLine());
Console.Write("Book Title: ");
string title = Console.ReadLine();
Console.Write("Author: ");
string author = Console.ReadLine();
Console.Write("Availability (true/false): ");
bool isAvailable = bool.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("Adding book in the Library......");
Book book = new Book(title, author, isAvailable);
_library.AddBook(book);
//Console.WriteLine("Below book details are added:");
//book.DisplayBookDetails();
}
public void RemoveBook()
{
Console.WriteLine();
Console.Write("Please enter the Book ID of the book to remove: ");
int id = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("Removing book from the Library......");
_library.RemoveBook(id);
}
}