Initial commit

This commit is contained in:
github-classroom[bot] 2025-02-25 17:10:54 +00:00 committed by GitHub
commit dcabbbaf15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 5246 additions and 0 deletions

3553
.editorconfig Normal file

File diff suppressed because it is too large Load diff

583
.gitignore vendored Normal file
View file

@ -0,0 +1,583 @@
# Created by https://www.toptal.com/developers/gitignore/api/csharp,visualstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=csharp,visualstudio
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
### VisualStudio ###
# User-specific files
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
# Build results
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
# MSTest test Results
# NUnit
# Build Results of an ATL Project
# Benchmark Results
# .NET Core
# ASP.NET Scaffolding
# StyleCop
# Files built by Visual Studio
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
# Coverlet is a free, cross platform Code Coverage Tool
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
# The packages folder can be ignored because of Package Restore
# except build/, which is used as an MSBuild target.
# Uncomment if necessary however generally it will be regenerated when needed
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# SQL Server files
# Business Intelligence projects
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
# Visual Studio 6 technical files
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
# Telerik's JustMock configuration file
# BizTalk build output
# OpenCover UI analysis results
# Azure Stream Analytics local run output
# MSBuild Binary and Structured Log
# NVidia Nsight GPU debugger configuration file
# MFractors (Xamarin productivity tool) working folder
# Local History for Visual Studio
# Visual Studio History (VSHistory) files
# BeatPulse healthcheck temp database
# Backup folder for Package Reference Convert tool in Visual Studio 2017
# Ionide (cross platform F# VS Code tools) working folder
# Fody - auto-generated XML schema
# VS Code files for those working on multiple tools
# Local History for Visual Studio Code
# Windows Installer files from build outputs
# JetBrains Rider
### VisualStudio Patch ###
# Additional files built by Visual Studio
# End of https://www.toptal.com/developers/gitignore/api/csharp,visualstudio

BIN
Data/vehicles.xlsx Normal file

Binary file not shown.

View file

@ -0,0 +1,44 @@
namespace Transport.Test;
public sealed class CarTests : TestBase
{
private static readonly Dictionary<int, (decimal bp, decimal ppk, decimal cpk)> carPriceAndCost = new()
{
[101] = (1.8M, 1.05M, 1M),
[102] = (3M, 1.008M, 0.96M),
[103] = (3.3M, 1.176M, 1.12M),
[104] = (4.8M, 1.134M, 1.08M)
};
[Fact]
public void CreateFromWorksheet()
{
List<Car> cars = Car.CreateFromWorksheet(LoadSheets().carWorksheet);
cars.Should()
.NotBeNull()
.And.NotBeEmpty()
.And.HaveCount(4)
.And.Contain(GetSampleCars());
}
[Fact]
public void PriceAndCost()
{
List<Car> cars = Car.CreateFromWorksheet(LoadSheets().carWorksheet);
foreach (var car in cars)
{
(car.BasePrice, car.PricePerKM, car.CostPerKM)
.Should().Be(carPriceAndCost[car.Id]);
}
}
private static List<Car> GetSampleCars() =>
[
CreateInstance<Car>(101, Color.Red, 1620, 26789.3D, 105, CarBrand.VW),
CreateInstance<Car>(102, Color.Blue, 1510, 122734.2D, 80, CarBrand.Dacia),
CreateInstance<Car>(103, Color.White, 2180, 45611.7D, 180, CarBrand.BMW),
CreateInstance<Car>(104, Color.Grey, 1798, 93417.8D, 204, CarBrand.AlfaRomeo)
];
}

View file

@ -0,0 +1,35 @@
namespace Transport.Test;
public sealed class RickshawTests : TestBase
{
[Fact]
public void CreateFromWorksheet()
{
List<Rickshaw> rickshaws = Rickshaw.CreateFromWorksheet(LoadSheets().rickshawWorksheet);
rickshaws.Should()
.NotBeNull()
.And.NotBeEmpty()
.And.HaveCount(2)
.And.Contain(GetSampleRickshaws());
}
[Fact]
public void PriceAndCost()
{
List<Rickshaw> rickshaws = Rickshaw.CreateFromWorksheet(LoadSheets().rickshawWorksheet);
foreach (var rickshaw in rickshaws)
{
rickshaw.CostPerKM.Should().Be(2.2M);
rickshaw.BasePrice.Should().Be(2M);
rickshaw.PricePerKM.Should().Be(2.5M);
}
}
private static List<Rickshaw> GetSampleRickshaws() =>
[
CreateInstance<Rickshaw>(201, Color.Black, 83, 381.5D),
CreateInstance<Rickshaw>(204, Color.Red, 102, 2178.2D)
];
}

View file

@ -0,0 +1,41 @@
namespace Transport.Test;
public sealed class RideTests : TestBase
{
private const double Start = 123.4D;
private const double Dist = 35.2D;
private const double End = Start + Dist;
[Fact]
public void Distance()
{
var ride = CreateSampleRide();
ride.Distance
.Should().BeApproximately(Dist, 1E-10);
}
[Fact]
public void TotalCost()
{
var ride = CreateSampleRide();
ride.TotalCost
.Should().Be(77.44M);
}
[Fact]
public void TotalPrice()
{
var ride = CreateSampleRide();
ride.TotalPrice
.Should().Be(90M);
}
private static Ride CreateSampleRide()
=> new("Susi", CreateSampleRickshaw(), Start, End);
private static Rickshaw CreateSampleRickshaw()
=> CreateInstance<Rickshaw>(201, Color.Black, 83, 381.5D);
}

View file

@ -0,0 +1,27 @@
using System.Reflection;
namespace Transport.Test;
public abstract class TestBase
{
protected static readonly string Path = System.IO.Path.Combine(Directory.GetCurrentDirectory(),
"Data/vehicles.xlsx");
protected static (IXLWorksheet carWorksheet, IXLWorksheet rickshawWorksheet) LoadSheets()
{
var workbook = new XLWorkbook(Path);
var rickshawSheet = workbook.Worksheet(Rickshaw.WorksheetName);
var carSheet = workbook.Worksheet(Car.WorksheetName);
return (carSheet, rickshawSheet);
}
protected static TVehicle CreateInstance<TVehicle>(params object?[] ctorParameters) where TVehicle : Vehicle
{
var ctor = typeof(TVehicle)
.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)
.Single();
return (TVehicle) ctor.Invoke(ctorParameters);
}
}

View file

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Using Include="FluentAssertions" />
<Using Include="Xunit" />
<Using Include="ClosedXML.Excel" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="8.0.0" />
<PackageReference Include="HTLLeonding.Utility.LeoAnalyzers" Version="1.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Transport\Transport.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Data\*.xlsx" Link="Data\%(RecursiveDir)%(Filename)%(Extension)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View file

@ -0,0 +1,70 @@
namespace Transport.Test;
public sealed class TravelManagementTests : TestBase
{
[Fact]
public void Initialize_FileFound()
{
Init();
}
[Fact]
public void Initialize_FileNotFound()
{
TravelManagement travelManagement = new();
travelManagement.InitializeFromFile("not-exists.xlsx")
.Should().BeFalse();
}
[Fact]
public void Rent_Car_Simple()
{
Init().RentVehicle<Car>("Hansi", 400D)
.Should().NotBeNull()
.And.Match<Car>(c => c.Id == 101 && !c.IsFree);
}
[Fact]
public void Rent_Car_Return()
{
var car = Init().RentVehicle<Car>("Hansi", 400D);
car.Should().NotBeNull()
.And.Match<Car>(c => c.Id == 101);
car?.EndRide()
.Should().Be((true, 421.8M));
car?.IsFree.Should().BeTrue();
}
[Fact]
public void Rent_Rickshaw_Simple()
{
var mgmt = Init();
mgmt.RentVehicle<Rickshaw>("Susi", 40D)
.Should().NotBeNull()
.And.Match<Rickshaw>(r => r.Id == 201, "newest avail. rickshaw");
mgmt.RentVehicle<Rickshaw>("Hansi", 25D)
.Should().NotBeNull()
.And.Match<Rickshaw>(r => r.Id == 204, "other rickshaw still en route");
}
[Fact]
public void Rent_DistanceTooHigh()
{
var mgmt = Init();
mgmt.RentVehicle<Rickshaw>("Hansi", 120D)
.Should().NotBeNull("car available")
.And.BeOfType<Car>("distance too high for rickshaw");
}
private static TravelManagement Init()
{
var mgmt = new TravelManagement();
mgmt.InitializeFromFile(Path).Should().BeTrue();
return mgmt;
}
}

31
Transport.sln Normal file
View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transport", "Transport\Transport.csproj", "{7F30E637-BAFE-42FA-A173-F42B3902ED3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Transport.Test", "Transport.Test\Transport.Test.csproj", "{161D9B2A-4E8B-43B6-A77E-40BED559521F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F30E637-BAFE-42FA-A173-F42B3902ED3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F30E637-BAFE-42FA-A173-F42B3902ED3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F30E637-BAFE-42FA-A173-F42B3902ED3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F30E637-BAFE-42FA-A173-F42B3902ED3B}.Release|Any CPU.Build.0 = Release|Any CPU
{161D9B2A-4E8B-43B6-A77E-40BED559521F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{161D9B2A-4E8B-43B6-A77E-40BED559521F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{161D9B2A-4E8B-43B6-A77E-40BED559521F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{161D9B2A-4E8B-43B6-A77E-40BED559521F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D322E690-379C-4802-8F7E-1AC6AD090D59}
EndGlobalSection
EndGlobal

71
Transport/Car.cs Normal file
View file

@ -0,0 +1,71 @@
namespace Transport;
/// <summary>
/// Represents a car
/// </summary>
/// <inheritdoc cref="Vehicle" />
public sealed class Car : Vehicle
{
/// <summary>
/// Name of the worksheet which contains the basic information of all cars
/// </summary>
public const string WorksheetName = $"{nameof(Car)}s";
private const decimal BaseCostPerKM = 0.8M;
private static readonly Dictionary<CarBrand, double> brandCoolness = new()
{
// TODO
};
private Car(int id, Color color, int weight, double initialMileage, double power, CarBrand brand)
: base(id, color, weight, initialMileage)
{
// TODO
}
/// <summary>
/// Gets the brand of the car
/// </summary>
public CarBrand Brand { get; }
/// <summary>
/// Gets the power of the car in kW
/// </summary>
public double Power { get; }
public override decimal BasePrice => -1; // TODO
public override decimal PricePerKM => -1; // TODO
public override decimal CostPerKM
{
get
{
// TODO
return -1;
}
}
/// <summary>
/// Creates a list of cars by parsing the data from the given worksheet.
/// Invalid rows are skipped.
/// </summary>
/// <param name="worksheet">Worksheet to process</param>
/// <returns>A list of cars</returns>
public static List<Car> CreateFromWorksheet(IXLWorksheet worksheet)
{
// TODO
return null!;
}
private bool Equals(Car other) => base.Equals(other) && Brand == other.Brand && Power.Equals(other.Power);
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || (obj is Car other && Equals(other));
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), (int) Brand, Power);
public static bool operator ==(Car? left, Car? right) => Equals(left, right);
public static bool operator !=(Car? left, Car? right) => !Equals(left, right);
}

33
Transport/Model.cs Normal file
View file

@ -0,0 +1,33 @@
namespace Transport;
/// <summary>
/// Possible vehicle colors
/// </summary>
public enum Color
{
Red,
Blue,
White,
Grey,
Black
}
/// <summary>
/// Available car brands
/// </summary>
public enum CarBrand
{
AlfaRomeo,
BMW,
Dacia,
VW
}
public sealed record Ride(string CustomerName, Vehicle Vehicle, double StartMileage, double EndMileage)
{
public double Distance => -1; // TODO
public decimal TotalCost => -1; // TODO
public decimal TotalPrice => -1; // TODO
private decimal TotalForDistance(decimal perKm) => -1; // TODO
}

100
Transport/Program.cs Normal file
View file

@ -0,0 +1,100 @@
using System.Text;
using Transport;
Console.OutputEncoding = Encoding.UTF8;
Console.WriteLine("*** Transport ***");
var mgmt = new TravelManagement();
mgmt.InitializeFromFile("Data/vehicles.xlsx");
var totalCost = 0M;
var rent01 = mgmt.RentVehicle<Car>("John Smith", 10.2);
var rent02 = mgmt.RentVehicle<Rickshaw>("Emily Johnson", 3.6);
var rent03 = mgmt.RentVehicle<Rickshaw>("Ryan Hernandez", 31.4);
var rent04 = mgmt.RentVehicle<Car>("David Brown", 78.2);
var rent05 = mgmt.RentVehicle<Car>("Emily Davis", 6.7);
ReturnVehicle(rent01);
ReturnVehicle(rent03);
ReturnVehicle(rent05);
rent01 = mgmt.RentVehicle<Rickshaw>("Robert Miller", 52.1);
rent03 = mgmt.RentVehicle<Car>("Jessica Lee", 7.8);
rent05 = mgmt.RentVehicle<Rickshaw>("Tyler Martin", 2.8);
var rent06 = mgmt.RentVehicle<Car>("Melissa Taylor", 93.5);
ReturnVehicle(rent02);
ReturnVehicle(rent04);
rent02 = mgmt.RentVehicle<Car>("Matthew Clark", 25.7);
rent04 = mgmt.RentVehicle<Car>("Sarah Davis", 46.9);
ReturnVehicle(rent01);
ReturnVehicle(rent02);
ReturnVehicle(rent03);
ReturnVehicle(rent04);
ReturnVehicle(rent05);
ReturnVehicle(rent06);
rent01 = mgmt.RentVehicle<Rickshaw>("Michael Martinez", 8.1);
rent02 = mgmt.RentVehicle<Rickshaw>("Ashley Lee", 5.2);
rent03 = mgmt.RentVehicle<Car>("Kevin Johnson", 77.3);
rent04 = mgmt.RentVehicle<Car>("Lauren Thompson", 59.8);
rent05 = mgmt.RentVehicle<Rickshaw>("Justin Scott", 7.6);
rent06 = mgmt.RentVehicle<Rickshaw>("Rachel Nguyen", 2.9);
ReturnVehicle(rent01);
ReturnVehicle(rent02);
ReturnVehicle(rent03);
ReturnVehicle(rent04);
rent01 = mgmt.RentVehicle<Car>("Erica Rodriguez", 111.2);
rent02 = mgmt.RentVehicle<Car>("Brandon Kim", 22.5);
ReturnVehicle(rent05);
ReturnVehicle(rent06);
rent03 = mgmt.RentVehicle<Rickshaw>("Kayla Lee", 11.7);
rent04 = mgmt.RentVehicle<Car>("Avery Williams", 41.2);
rent05 = mgmt.RentVehicle<Rickshaw>("Jenna Kim", 4.9);
rent06 = mgmt.RentVehicle<Car>("Daniel Nguyen", 111.2);
ReturnVehicle(rent01);
rent01 = mgmt.RentVehicle<Rickshaw>("Alexis Lee", 3.3);
ReturnVehicle(rent01);
ReturnVehicle(rent02);
ReturnVehicle(rent03);
rent01 = mgmt.RentVehicle<Car>("Olivia Baker", 57.2);
rent02 = mgmt.RentVehicle<Car>("Connor Smith", 38.8);
rent03 = mgmt.RentVehicle<Rickshaw>("Gabriel Lee", 10.2);
ReturnVehicle(rent01);
ReturnVehicle(rent02);
ReturnVehicle(rent03);
ReturnVehicle(rent04);
ReturnVehicle(rent05);
ReturnVehicle(rent06);
Console.WriteLine($"Total cost of all rides: {totalCost:C2}");
var travelLog = mgmt.GetTravelLog();
var fileName = $"travel-log-{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.xlsx";
string filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
travelLog.SaveAs(filePath);
Console.WriteLine($"Travel log saved to: {filePath}");
return;
void ReturnVehicle(Vehicle? rentedVehicle)
{
if (rentedVehicle is not null)
{
totalCost += rentedVehicle.EndRide().price ?? 0;
}
}

32
Transport/Rickshaw.cs Normal file
View file

@ -0,0 +1,32 @@
namespace Transport;
/// <summary>
/// Represents a rickshaw which can be rented for a ride
/// </summary>
/// <inheritdoc cref="Vehicle" />
public sealed class Rickshaw : Vehicle
{
/// <summary>
/// Name of the worksheet which contains the basic information of all rickshaws
/// </summary>
public const string WorksheetName = $"{nameof(Rickshaw)}s";
private Rickshaw(int id, Color color, int weight, double initialMileage)
: base(id, color, weight, initialMileage) { }
public override decimal BasePrice => -1; // TODO
public override decimal PricePerKM => -1; // TODO
public override decimal CostPerKM => -1; // TODO
/// <summary>
/// Creates a list of rickshaws by parsing the data from the given worksheet.
/// Invalid rows are skipped.
/// </summary>
/// <param name="worksheet">Worksheet to process</param>
/// <returns>A list of rickshaws</returns>
public static List<Rickshaw> CreateFromWorksheet(IXLWorksheet worksheet)
{
// TODO
return null!;
}
}

View file

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.104.2" />
<PackageReference Include="HTLLeonding.Utility.LeoAnalyzers" Version="1.0.2" />
</ItemGroup>
<ItemGroup>
<Using Include="ClosedXML.Excel" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Data\*.xlsx" Link="Data\%(RecursiveDir)%(Filename)%(Extension)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View file

@ -0,0 +1,72 @@
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;
}
}

199
Transport/Vehicle.cs Normal file
View file

@ -0,0 +1,199 @@
using System.Globalization;
namespace Transport;
/// <summary>
/// Represents a vehicle which can be rented for a ride
/// </summary>
public abstract class Vehicle
{
private readonly List<Ride> _rides;
private RentalInfo? _rentalInfo;
protected Vehicle(int id, Color color, int weight, double initialMileage)
{
Id = id;
Color = color;
Weight = weight;
Mileage = initialMileage;
_rides = [];
}
/// <summary>
/// Gets the base price of the vehicle per rental
/// </summary>
public abstract decimal BasePrice { get; }
/// <summary>
/// Gets the price per km
/// </summary>
public abstract decimal PricePerKM { get; }
/// <summary>
/// Gets the cost per km
/// </summary>
public abstract decimal CostPerKM { get; }
/// <summary>
/// Gets the color of the vehicle
/// </summary>
public Color Color { get; }
/// <summary>
/// Gets the weight of the vehicle
/// </summary>
public int Weight { get; }
/// <summary>
/// Gets the unique id of the vehicle
/// </summary>
public int Id { get; }
/// <summary>
/// Gets the current mileage of the vehicle
/// </summary>
public double Mileage { get; private set; }
/// <summary>
/// Gets if the vehicle is available for rent
/// </summary>
public bool IsFree => _rentalInfo is null;
/// <summary>
/// Rents the vehicle for a ride of the specified distance
/// </summary>
/// <param name="customerName">Name of the customer renting the vehicle</param>
/// <param name="distance">Distance of the ride</param>
/// <returns>True if the vehicle could be rented; false otherwise</returns>
public bool Rent(string customerName, double distance)
{
// TODO
return false;
}
/// <summary>
/// Ends the current (rental) ride.
/// A ride can only be ended if the vehicle was rented in the first place.
/// </summary>
/// <returns>A flag indicating if the ride was ended and the total price to pay for it</returns>
public (bool success, decimal? price) EndRide()
{
// TODO
return (false, null);
}
/// <summary>
/// Adds the travel log sheet for this vehicle to the supplied workbook.
/// Only creates the sheet if the vehicle has been used at least one ride.
/// </summary>
/// <param name="workbook">The workbook to add to</param>
public void AddTravelLogSheet(IXLWorkbook workbook)
{
// TODO
// static string FormatCurrency(decimal v) => Format((double) v);
// static string Format(double v) => v.ToString("F2", NumberFormatInfo.InvariantInfo);
}
/// <summary>
/// Reads data in the given excel row and turns it into an easier to process instance of <see cref="ExcelData" />
/// </summary>
/// <param name="row">Row to process</param>
/// <param name="columnCount">Number of columns to process</param>
/// <returns>Data of the row, if it could be parsed</returns>
protected static ExcelData? ProcessExcelRow(IXLRow row, int columnCount)
{
// TODO
return null;
/*
string? GetValue(int col)
{
string? val = row.Cell(col).GetValue<string?>();
return string.IsNullOrWhiteSpace(val) ? null : val;
}
*/
}
/// <summary>
/// Gets all rows from the given worksheet, excluding the header row
/// </summary>
/// <param name="worksheet">Worksheet to process</param>
/// <returns>Rows in the worksheet</returns>
protected static List<IXLRow> GetRowsFromWorksheet(IXLWorksheet worksheet) =>
worksheet.Rows().ToArray()[1..].ToList();
/// <summary>
/// Tries to parse the given string as a double, using the invariant culture
/// </summary>
/// <param name="value">Value to parse</param>
/// <param name="result">Parsed value</param>
/// <returns>True if parsing succeeded; false otherwise</returns>
protected static bool TryParseDoubleInvariant(string? value, out double result)
{
if (string.IsNullOrWhiteSpace(value))
{
result = 0D;
return false;
}
return double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
}
/// <summary>
/// Gets the number of used columns in the given worksheet
/// </summary>
/// <param name="worksheet">Worksheet to process</param>
/// <returns>The number of columns</returns>
protected static int GetColumnsOfWorksheet(IXLWorksheet worksheet) => worksheet.ColumnsUsed().Count();
protected bool Equals(Vehicle other) =>
Color == other.Color && Weight == other.Weight && Id == other.Id && Mileage.Equals(other.Mileage);
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((Vehicle) obj);
}
public override int GetHashCode() => HashCode.Combine((int) Color, Weight, Id);
public static bool operator ==(Vehicle? left, Vehicle? right) => Equals(left, right);
public static bool operator !=(Vehicle? left, Vehicle? right) => !Equals(left, right);
/// <summary>
/// Contains the already parsed common properties of each vehicle.
/// May contain additional columns for properties of more specialized vehicles.
/// </summary>
/// <param name="Id">Unique id of the vehicle</param>
/// <param name="Color">Color of the vehicle</param>
/// <param name="Weight">Weight of the vehicle in kg</param>
/// <param name="InitialMileage">Mileage of the vehicle before the first ride</param>
/// <param name="AdditionalCellValues">Optional additional (raw) values</param>
protected sealed record ExcelData(int Id, Color Color, int Weight, double InitialMileage,
List<string?> AdditionalCellValues);
/// <summary>
/// Represents basic information about a rental
/// </summary>
/// <param name="CustomerName">Name of the customer who rented the vehicle</param>
/// <param name="Distance">Distance of the ride</param>
protected sealed record RentalInfo(string CustomerName, double Distance);
}

BIN
pics/car.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

BIN
pics/rickshaw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 KiB

BIN
pics/travel_log_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
pics/travel_log_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
pics/travel_log_03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
pics/travel_log_04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
pics/travel_log_05.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
pics/travel_log_06.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

287
readme.adoc Normal file
View file

@ -0,0 +1,287 @@
:sectnums:
:nofooter:
:toc: left
:icons: font
:data-uri:
:source-highlighter: highlightjs
:stem: latexmath
= Inh.05 -- Transport
You need to implement a management system for a vehicle rental business.
Customers can rent a vehicle for a trip.
For that they have to pay a fee which is dependent on various factors.
The vehicles incur costs for the company.
The goal is to make a profit!
The _special_ feature of this exercise is that you will read & create the most important data format for every company all over the world: **Excel documents** 😮
WARNING: The specifics of this assignment did not allow to provide extensive unit tests -- otherwise big parts of the implementation would have to be duplicated/visible in the tests. So you can't rely on tests, but have to check the output files to see if your implementation is looking good.
== Data Model
[plantuml]
----
@startuml
hide empty methods
abstract class Vehicle {
-List<Ride> _rides [readonly]
-RentalInfo? _rentalInfo
{abstract} +decimal BasePrice [readonly]
{abstract} +decimal PricePerKM [readonly]
{abstract} +decimal CostPerKM [readonly]
+Color Color [readonly]
+int Weight [readonly]
+int Id [readonly]
+double Mileage [private set]
+bool IsFree [readonly]
#Vehicle(int, Color, int, double)
+bool Rent(string, double)
+(bool, decimal?) EndRide()
+void AddTravelLogSheet(IXLWorkbook)
{static} #ExcelData? ProcessExcelRow(IXLRow, int)
{static} #List<IXLRow> GetRowsFromWorksheet(IXLWorksheet)
{static} #bool TryParseDoubleInvariant(string?, out double)
{static} #int GetColumnsOfWorksheet(IXLWorksheet)
}
class Car <<sealed>> {
+string WorksheetName [const]
-decimal BaseCostPerKM
{static} -Dictionary<CarBrand, double> brandCoolness [readonly]
+CarBrand Brand [readonly]
+double Power [readonly]
{static} +List<Car> CreateFromWorksheet(IXLWorksheet)
}
class Rickshaw <<sealed>> {
+string WorksheetName [const]
{static} +List<Rickshaw> CreateFromWorksheet(IXLWorksheet)
}
class Ride <<record,sealed>> {
+string CustomerName [readonly]
+Vehicle Vehicle [readonly]
+double StartMileage [readonly]
+double EndMileage [readonly]
+double Distance [readonly]
+decimal TotalCost [readonly]
+decimal TotalPrice [readonly]
-decimal TotalForDistance(decimal)
}
class TravelManagement <<sealed>> {
+double MaxRickshawDistance [const]
-List<Vehicle> _vehicles [readonly]
+TravelManagement()
+bool InitializeFromFile(string)
+Vehicle? RentVehicle<TPreferredVehicle>(string, double)
+IXLWorkbook GetTravelLog()
}
enum Color {
Red
Blue
White
Grey
Black
}
enum CarBrand
{
AlfaRomeo
BMW
Dacia
VW
}
Vehicle <|-- Car
Vehicle <|-- Rickshaw
Vehicle o-- Ride
Ride *-- Vehicle
Vehicle *-- Color
Car *-u- CarBrand
TravelManagement o-r- Vehicle
note top of Vehicle : + Equality members
@enduml
----
== Vehicles
Currently, two types of vehicles are available:
* Rickshaws
* Cars
[cols="a,a",frame=none, grid=none]
|===
| image::pics/rickshaw.png[Rickshaw]
| image::pics/car.jpg[Car]
|===
Each vehicle has the following properties:
* `Id`
** Unique
** Cannot be stem:[<0]
* `Color`
* `Weight`
** Cannot be stem:[<0]
* `Mileage`
** Initial mileage before rides are performed
*** => will change after each ride
** Cannot be stem:[<0]
=== Rickshaw
* Has no additional properties
* Has the following, _fixed_ values:
** `BasePrice`: 2
** `PricePerKM`: 2.5
** `CostPerKM`: 2.2
=== Car
* Has the following, additional properties:
** `Brand`
** `Power` (engine power in kw)
*** Cannot be stem:[<=0]
* Has the following, _dynamic_ values:
** `BasePrice`: stem:[3 * CoolnessOfBrand]
** `PricePerKM`: stem:[CostPerKM * 1.05]
*** We want to make a profit after all
** `CostPerKM`: stem:[BaseCostPerKM * (\frac{engineFactor + weightFactor}{100} + 1)]
.CoolnessOfBrand
|===
|Brand |Coolness
|AlfaRomeo
|stem:[1.6]
|BMW
|stem:[1.1]
|Dacia
|stem:[1]
|VW
|stem:[0.6]
|===
.engineFactor
|===
|Power |Factor
|stem:[<= 66]
|stem:[0]
|stem:[<= 88]
|stem:[5]
|stem:[<= 110]
|stem:[10]
|stem:[> 110]
|stem:[20]
|===
.weightFactor
|===
|Weight |Factor
|stem:[< 1000]
|stem:[0]
|stem:[< 1500]
|stem:[10]
|stem:[< 2000]
|stem:[15]
|stem:[< 2400]
|stem:[20]
|stem:[>= 2400]
|stem:[25]
|===
== Excel
As stated before you'll have to read & write Excel files.
That is important, because almost every clerk knows Excel, so the most request import & export format in any application is always 'Excel!' -- no matter if there would be technically better suited formats.
There is also an old joke 'no matter how much code we write, the world continues to run on Excel'.
TIP: Try to open any `*.xlsx` File in a text editor: you'll realize that will be harder to process than CSV.
Contrary to simple text (or binary) files like CSV, Excel files allow for advanced formatting.
Each cell can for example have a type (e.g. format as number, as text, as date,...), a style (e.g. bold, italics, font, font size,...) or even a formula (e.g. SUM,...).
Columns, rows and cells can also be addressed by 'name', e.g. `A4`.
And finally, one file (= workbook) can contain multiple worksheets.
For this assignment we'll stick to basic features, but knowing how to read & create such complex files will be a valuable skill for you to have.
To process Excel file we are going to use a free & open source library called https://github.com/ClosedXML/ClosedXML[ClosedXML].
The appropriate https://www.nuget.org/packages/ClosedXML/[NuGet] package has already been added to your starter project.
However, learning how to use the API is mostly up to you -- _it might be a good idea to read the documentation_ 😉.
Several methods already accept or return types you'll need (e.g. `IXLWorksheet`), these are a good starting point for your research.
== Program Description
The program runs through the following steps:
. Vehicle data is read from the file `vehicles.xlsx`
** Each worksheet contains data for one type of vehicle
** Invalid rows are skipped
. Several rental operations are performed
** The ride information is stored by each vehicle
. The travel log is written to a `travel-log-{date&time}.xlsx` file
** The workbook contains multiple sheets -- one for each vehicle
*** Only vehicles with at least one ride create a sheet
** Each sheet contains the rentals/rides of one vehicle
=== Implementation Hints & Requirements
A couple of additional explanations for several, more complex methods:
* `Vehicle.EndRide`
** Ending an active rental (ride) adds this ride to the list of rides and increases the mileage accordingly
** The vehicle is then free to be rented again
* `Vehicle.GetColumnsOfWorksheet`
** Returns the number of _used_ columns in the given sheet
** A column is used if any of its cells has a non-empty value
* `TravelManagement.InitializeFromFile`
** Populates the internal list of vehicles
** Make use of the `CreateFromWorksheet` methods
** You might want to use https://learn.microsoft.com/en-us/dotnet/api/system.io.file.exists[`File.Exists`] to check if a file exists
* `TravelManagement.RentVehicle`
** Selects a _free_ vehicle of the specified type with the _lowest_ mileage of all vehicles of this type => the least worn vehicles are preferred
*** If the required distance exceeds the limit for a `Rickshaw` a `Car` is selected instead
** You can use `typeof(TPreferredVehicle)` to get the requested type
*** If you are unsure what that operator does https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/type-testing-and-cast#typeof-operator[read up on it]
** To find out the _runtime type_ of an _instance_ https://learn.microsoft.com/en-us/dotnet/api/system.object.gettype?view=net-8.0[use the `GetType()`] method
TIP: Also carefully read the provided XMLDoc, it contains valueable information
== Tasks
. Learn how to use the ClosedXML library
. Complete the application
. Ensure that the sample run in `Program` leads to a result as defined below
** This includes the _formatting_ in the Excel file!
=== Sample Run
Executing `Program` should result in this console output:
[source]
----
*** Transport ***
Total cost of all rides: € 1.114,15
Travel log saved to: <path-to-file>\travel-log-<date&time>.xlsx
----
The created travel log file should contain the following worksheets with these values and the proper formatting:
image::pics/travel_log_01.png[TravelLog]
image::pics/travel_log_02.png[TravelLog]
image::pics/travel_log_03.png[TravelLog]
image::pics/travel_log_04.png[TravelLog]
image::pics/travel_log_05.png[TravelLog]
image::pics/travel_log_06.png[TravelLog]