-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Reservation.cs
30 lines (27 loc) · 861 Bytes
/
Reservation.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
using System;
namespace CarRentalSystem
{
public class Reservation
{
public string ReservationId { get; }
public Customer Customer { get; }
public Car Car { get; }
public DateTime StartDate { get; }
public DateTime EndDate { get; }
public double TotalPrice { get; }
public Reservation(string reservationId, Customer customer, Car car, DateTime startDate, DateTime endDate)
{
ReservationId = reservationId;
Customer = customer;
Car = car;
StartDate = startDate;
EndDate = endDate;
TotalPrice = CalculateTotalPrice();
}
private double CalculateTotalPrice()
{
int daysRented = (EndDate - StartDate).Days + 1;
return Car.RentalPricePerDay * daysRented;
}
}
}