-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
42 lines (39 loc) · 1.71 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
using System.Globalization;
using exceptions.Entities;
using exceptions.Entities.Exceptions;
public class Program
{
public 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.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
Console.Write("Check-out date (dd/MM/yyyy): ");
DateTime checkOut = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
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.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
Console.Write("Check-out date (dd/MM/yyyy): ");
checkOut = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
reservation.UpdateDates(checkIn, checkOut);
Console.WriteLine($"Reservation: {reservation}");
}
catch(DomainException e)
{
Console.WriteLine("Error in reservation: " + e.Message);
}
catch(FormatException e)
{
Console.WriteLine("Format error: " + e.Message);
}
catch(Exception e) //captar qualquer outra excessão que não foi especificada antes.
{
Console.WriteLine("Unexpected error: " + e.Message);
}
}
}