Created
September 8, 2015 20:14
-
-
Save cohen990/e07850cf25d4199c069a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var me = new Person(); | |
var myCar = new Car(); | |
#region carJourney | |
GoOnAJourney(me, myCar); | |
DriveSomewhere(me, myCar); | |
#endregion | |
#region airplane journey | |
GoOnAJourney(me, new AirPlane()); | |
FlySomewhere(me, new AirPlane()); | |
#endregion | |
} | |
public static void GoOnAJourney(Person traveller, ITransportation transportation) | |
{ | |
if (transportation.Passengers.Count < transportation.MaxCapacity) | |
{ | |
transportation.Embark(traveller); | |
transportation.Go(); | |
transportation.Disembark(traveller); | |
} | |
else { return; } | |
} | |
public static void DriveSomewhere(Person traveller, Car myCar) | |
{ | |
if (myCar.Passengers.Count < myCar.MaxCapacity) | |
{ | |
myCar.Embark(traveller); | |
myCar.Go(); | |
myCar.Disembark(traveller); | |
} | |
else { return; } | |
} | |
public static void FlySomewhere(Person traveller, AirPlane plane) | |
{ | |
if (plane.Passengers.Count < plane.MaxCapacity) | |
{ | |
plane.Embark(traveller); | |
plane.Go(); | |
plane.Disembark(traveller); | |
} | |
else { return; } | |
} | |
} | |
public interface ITransportation | |
{ | |
List<Person> Passengers { get; } | |
TimeSpan ExpectedJourneyDuration { get; } | |
int MaxCapacity { get; } | |
void Embark(Person personToBoard); | |
void Disembark(Person personToDisembark); | |
void Go(); | |
} | |
public class Car : ITransportation | |
{ | |
public TimeSpan ExpectedJourneyDuration { get; } | |
public List<Person> Passengers { get; } | |
public int MaxCapacity { get; } | |
public Car() | |
{ | |
ExpectedJourneyDuration = TimeSpan.FromMinutes(20); | |
Passengers = new List<Person>(); | |
MaxCapacity = 4; | |
} | |
public void Disembark(Person personToDisembark) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Embark(Person personToBoard) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Go() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public class AirPlane : ITransportation | |
{ | |
public TimeSpan ExpectedJourneyDuration | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public int MaxCapacity | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public List<Person> Passengers | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public void Disembark(Person personToDisembark) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Embark(Person personToBoard) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Go() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment