I'm writing some console application and for example I have different classes which I want to be able to call in my application for printing output.
// For example I have Vehicle class and method Park in it
public void Park()
{
if (Parking.ParkedVehicles.Count < ParkingSettings.ParkingCapacity)
{
Parking.ParkedVehicles.Add(this);
_isParked = true;
Console.WriteLine("Your vehicle(" + Color + " " + Make + "," +
LicenseNumber + ") was parked successfully. Go be pedestrian somewhere else");
}
else
{
Console.WriteLine("Sorry. Unfortunately all parking slots are occupied, try again next time");
}
}
And Parking
class with PrintOccupanctStatus()
method in it
public static void PrintOccupancyStatus()
{
if (ParkedVehicles.Count < ParkingSettings.ParkingCapacity)
{
Console.WriteLine($"Currently there are {ParkingSettings.ParkingCapacity - ParkedVehicles.Count} spots left");
}
else
{
Console.WriteLine("Sorry, parking has no free spots left");
}
}
So these are two different independent classes and I'm calling them in my console app. Is it considered an "OKAY" approach or should I do something like ConsoleHelper
to print results and make above methods return string instead?