ex-inh-05-transport/Transport/TravelManagement.cs
github-classroom[bot] dcabbbaf15
Initial commit
2025-02-25 17:10:54 +00:00

72 lines
2.5 KiB
C#

namespace Transport;
/// <summary>
/// Represents management of all available vehicles and performed rides.
/// </summary>
public sealed class TravelManagement
{
/// <summary>
/// The max. distance a rickshaw can travel during a single rental
/// </summary>
public const double MaxRickshawDistance = 50D;
private readonly List<Vehicle> _vehicles;
/// <summary>
/// Creates a new instance of the management
/// </summary>
public TravelManagement()
{
_vehicles = [];
}
/// <summary>
/// Loads the available vehicles from the Excel file at the given location
/// </summary>
/// <param name="filePath">Path to the workbook</param>
/// <returns>True if loading was successful; false otherwise</returns>
public bool InitializeFromFile(string filePath)
{
// TODO
var workbook = new XLWorkbook(filePath);
var rickshawSheet = workbook.Worksheet(Rickshaw.WorksheetName);
var carSheet = workbook.Worksheet(Car.WorksheetName);
// TODO
return false;
}
/// <summary>
/// Attempts to rent a vehicle for the given distance and customer.
/// Important: the distance is (unrealistically) fixed: it will be
/// exactly the given value, neither shorter nor longer.
/// If a <see cref="Rickshaw"/> is requested but the distance exceeds <see cref="MaxRickshawDistance"/>
/// a <see cref="Car"/> is selected instead.
/// Only vehicles currently available (= not on a ride) are considered.
/// </summary>
/// <param name="customerName">Name of the customer who desires to rent a vehicle</param>
/// <param name="distance">The distance for which the vehicle is rented</param>
/// <typeparam name="TPreferredVehicle">Desired vehicle type</typeparam>
/// <returns>The rented vehicle, if a matching one has been found</returns>
public Vehicle? RentVehicle<TPreferredVehicle>(string customerName, double distance)
where TPreferredVehicle : Vehicle
{
// TODO
return null;
}
/// <summary>
/// Creates an Excel workbook which contains a worksheet for every vehicle.
/// Each worksheet contains the detail travel log of all rentals for one vehicle.
/// </summary>
/// <returns>Workbook containing travel log of all vehicles</returns>
public IXLWorkbook GetTravelLog()
{
IXLWorkbook workbook = new XLWorkbook();
// TODO
return workbook;
}
}