-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVehicle.cs
64 lines (54 loc) · 1.77 KB
/
Vehicle.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
namespace Vehicle_Rental_System
{
internal class Vehicle
{
public string CustomerName { get; set; }
public string Brand { get; set; }
public string Model { get; set; }
public decimal Value { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public DateTime ReturnDate { get; set; }
// constructor
public Vehicle(string CustomerName, string Brand, string Model, decimal Value, DateTime StartDate, DateTime EndDate, DateTime ReturnDate)
{
this.CustomerName = CustomerName;
this.Brand = Brand;
this.Model = Model;
this.Value = Value;
this.StartDate = StartDate;
this.EndDate = EndDate;
this.ReturnDate = ReturnDate;
}
public int ReservationPeriod()
{
return (EndDate - StartDate).Days;
}
public int ActualRentalPeriod()
{
// if returned ahead of time, rental period is reduced, else it's the ReservationPeriod
// e.g. if it's rented for 10days and returned on the 5th, RentalPeriod = 5
if (ReturnDate < EndDate)
{
return (ReturnDate - StartDate).Days;
}
return ReservationPeriod();
}
// virtual methods so it's possible to override them in the derived classes
#region Virtuals
public virtual decimal GetDailyRentalCost()
{
return 0m;
}
public virtual decimal DailyInsuranceCost()
{
return 0m;
}
public virtual decimal AdjustDailyInsuranceCost()
{
return 0m;
}
#endregion
}
}