-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
117 lines (103 loc) · 4.92 KB
/
Program.cs
File metadata and controls
117 lines (103 loc) · 4.92 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Library_Management_System
{
public class Program
{
static void Main(string[] args)
{
Library library = new Library();
Console.WriteLine(" <-Welcome to the Library System->");
Console.WriteLine("Are you Librarian or regular user? (L / R)?");
char usertype = Console.ReadLine().ToUpper()[0];
if (usertype == 'L')
{
Console.Write("Welcome Librarian, Enter your Name -> ");
string librarianName = Console.ReadLine();
Librarian li = new Librarian(librarianName);
Console.WriteLine($"Welcome {li.Name}");
while (true)
{
Console.WriteLine($"Please choose to Add Book (A) / Remove Book (R) / Display Books (D)?");
char choice = Console.ReadLine().ToUpper()[0];
switch (choice)
{
case 'A':
Console.WriteLine("Enter Book Details Addind");
Console.WriteLine("=============================");
Console.Write("Enter Title Book -> ");
string TitleBook = Console.ReadLine();
Console.Write("Enter Author Book -> ");
string AuthorBook = Console.ReadLine();
Console.Write("Enter Year Book -> ");
int YearBook = Convert.ToInt32(Console.ReadLine());
Book book = new Book(YearBook, TitleBook, AuthorBook);
li.AddBook(book, library);
break;
case 'R':
Console.WriteLine("Enter Book Details Removing");
Console.WriteLine("=============================");
Console.Write("Enter Title Book -> ");
TitleBook = Console.ReadLine();
Console.Write("Enter Author Book -> ");
AuthorBook = Console.ReadLine();
Console.Write("Enter Year Book -> ");
YearBook = Convert.ToInt32(Console.ReadLine());
book = new Book(YearBook, TitleBook, AuthorBook);
li.RemoveBook(book, library);
break;
case 'D':
Console.WriteLine("The Book List : ");
li.DisplayBooks(library);
break;
default:
Environment.Exit(0);
break;
}
}
}
else if (usertype == 'R')
{
Console.Write("Welcome User, Enter your Name -> ");
string UserName = Console.ReadLine();
LibraryUser u1 = new LibraryUser(UserName);
Console.WriteLine($"Welcome {u1.Name}");
while (true)
{
Console.WriteLine($"Please choose to Borrow Book(B) / Display Books (D)?");
char choice = Console.ReadLine().ToUpper()[0];
switch (choice)
{
case 'B':
Console.WriteLine("Enter Book Borrow Details");
Console.WriteLine("=============================");
Console.Write("Enter Title Book -> ");
string TitleBook = Console.ReadLine();
Console.Write("Enter Author Book -> ");
string AuthorBook = Console.ReadLine();
Console.Write("Enter Year Book -> ");
int YearBook = Convert.ToInt32(Console.ReadLine());
Book book = new Book(YearBook, TitleBook, AuthorBook);
u1.BorrowBooks(book, library);
break;
case 'D':
Console.WriteLine("The Book List : ");
u1.DisplayBooks(library);
break;
default:
Environment.Exit(0);
break;
}
}
}
else
{
Console.WriteLine("Please enter Correct Value (L or R)");
}
Console.ReadKey();
}
}
}