-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (47 loc) · 1.39 KB
/
Copy pathProgram.cs
File metadata and controls
58 lines (47 loc) · 1.39 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
// Program.cs
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to the Daryl's Library!");
BookLibrary bookLibrary = new BookLibrary();
bookLibrary.DisplayBookList();
Console.Write("Enter the number of books you need: ");
int numberOfBooks;
if (!int.TryParse(Console.ReadLine(), out numberOfBooks))
{
Console.WriteLine("Invalid input. Please enter a valid input.");
return;
}
Console.WriteLine();
for (int i = 1; i <= numberOfBooks; i++)
{
Console.WriteLine($"Book #{i}");
Book book = new Book();
book.Title = GetBookTitle();
book.NumberOfDays = GetNumberOfDays();
book.PrintExpectedReturnDate();
}
Console.WriteLine("Thank you for using the Daryl's Library!");
Console.ReadKey();
}
static string GetBookTitle()
{
Console.Write("Enter the title of the book: ");
return Console.ReadLine();
}
static int GetNumberOfDays()
{
Console.Write("Enter the number of days you need the book: ");
if (int.TryParse(Console.ReadLine(), out int numberOfDays))
{
return numberOfDays;
}
else
{
Console.WriteLine("Invalid input.");
return 0;
}
}
}