-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
48 lines (43 loc) · 1.64 KB
/
Program.cs
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
using System;
using HotelReservations.Entities;
using HotelReservations.Entities.Exceptions;
namespace Course
{
class Program
{
static void Main(string[] args)
{
try
{
Console.Write("Room number: ");
int number = int.Parse(Console.ReadLine());
Console.Write("Check-in date (dd/MM/yyyy): ");
DateTime checkIn = DateTime.Parse(Console.ReadLine());
Console.Write("Check-out date (dd/MM/yyyy): ");
DateTime checkOut = DateTime.Parse(Console.ReadLine());
Reservation reservation = new Reservation(number, checkIn, checkOut);
Console.WriteLine("Reservation: " + reservation);
Console.WriteLine();
Console.WriteLine("Enter data to update the reservation:");
Console.Write("Check-in date (dd/MM/yyyy): ");
checkIn = DateTime.Parse(Console.ReadLine());
Console.Write("Check-out date (dd/MM/yyyy): ");
checkOut = DateTime.Parse(Console.ReadLine());
reservation.UpdateDates(checkIn, checkOut);
Console.WriteLine("Reservation: " + reservation);
}
catch (FormatException e)
{
Console.WriteLine("Error in format: " + e.Message);
}
catch (DomainException e)
{
Console.WriteLine("Error in reservation: " + e.Message);
}
catch (Exception e)
{
Console.WriteLine("Unexpected error: " + e.Message);
}
}
}
}