-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrarySystem2
More file actions
106 lines (91 loc) · 3.05 KB
/
Copy pathLibrarySystem2
File metadata and controls
106 lines (91 loc) · 3.05 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
using System;
class Program
{
static string[] bookTitles = {
"Beauty Queens – Libba Bray",
"Before I Let Go – Marieke Nijkamp",
"The Belles (#1) – Dhonielle Clayton",
"Big Bones – Laura Dockrill",
"Caraval – Stephanie Garber",
"Coraline – Neil Gaiman",
"Dangerous Lies – Becca Fitzpatrick",
"Descendants – Rae Else",
"Fangirl – Rainbow Rowell",
"Final Girls – Riley Sager",
"Girlhood – Cat Clarke",
"Hades – Alexandra Adornetto",
"Heaven – Alexandra Adornetto",
"Home Fire – Kamila Shamsie",
"Internment – Samira Ahmed",
"Kindred Spirits – Rainbow Rowell",
"Milk and Honey – Rupi Kaur",
"Oleanna – David Mamet",
"Paintbrush – Hannah Bucchin",
"Zenn Diagram – Wendy Brant"
};
static void Main(string[] args)
{
Console.WriteLine("Welcome to the Daryl's Library!");
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}");
string title = GetBookTitle();
int numberOfDays = GetNumberOfDays();
DateTime currentDate = GetCurrentDate();
DateTime expectedReturnDate = currentDate.AddDays(numberOfDays);
Console.WriteLine($"Expected return date for {title}: {expectedReturnDate.ToString("dd/MM/yyyy")}");
Console.WriteLine();
}
Console.WriteLine("Thank you for using the Daryl's Library!");
Console.ReadKey();
}
static void DisplayBookList()
{
Console.WriteLine("LIST OF BOOKS:");
for (int i = 0; i < bookTitles.Length; i++)
{
Console.WriteLine($"{i + 1}. {bookTitles[i]}");
}
Console.WriteLine();
}
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;
}
}
static DateTime GetCurrentDate()
{
Console.Write("Enter the current date (format: dd/MM/yyyy): ");
if (DateTime.TryParseExact(Console.ReadLine(), "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out DateTime currentDate))
{
return currentDate;
}
else
{
Console.WriteLine("Invalid input. Please enter in the format: dd/MM/yyyy.");
return DateTime.MinValue;
}
}
}