Skip to content

Instantly share code, notes, and snippets.

@telphan
Created January 30, 2026 15:09
Show Gist options
  • Select an option

  • Save telphan/fc9523dde44842d7f7e12519619adc47 to your computer and use it in GitHub Desktop.

Select an option

Save telphan/fc9523dde44842d7f7e12519619adc47 to your computer and use it in GitHub Desktop.
// To run first create a new project with:
// dotnet new console
// Edit the Program.cs file adding a call to Question.Results()
// Then run with
// dotnet run
public class Question
{
public static void Results()
{
var responses = new List<Object>();
responses.Add(new DuffelAirResponse("JFK", "LGW", "18:00", "17:50", "432GBP"));
responses.Add(new VirginResponse("JFK/LGW", "18:00", "17:50", "12300", "GBP"));
responses.Add(new VirginResponse("JFK/LGW", "15:00", "19:30", "10900", "GBP"));
responses.Add(new AAResponse("jfk", "lgw", "2020-07-23 09:01:20 +0000", "2020-07-23 12:07:53 +0000", new Price("315.50", "USD")));
responses.Add(new BAResponse("jfk", "lgw", "2020-07-23 09:01:20 +0000", "542", new Price("425.50", "USD")));
responses.ForEach((response)=>Console.WriteLine(string.Join(", ",response)));
}
}
public class AAResponse
{
private String originCode;
private String destinationCode;
private String departureDateTime;
private String arrivalDateTime;
private Price price;
public AAResponse(String originCode, String destinationCode, String departureDateTime, String arrivalDateTime, Price price)
{
this.originCode = originCode;
this.destinationCode = destinationCode;
this.departureDateTime = departureDateTime;
this.arrivalDateTime = arrivalDateTime;
this.price = price;
}
public override String ToString()
{
return $"AA {this.originCode} {this.destinationCode} {this.departureDateTime} {this.arrivalDateTime} {this.price}";
}
}
public class BAResponse
{
private String originCode;
private String destinationCode;
private String takeOffAt;
private String duration;
private Price price;
public BAResponse(String originCode, String destinationCode, String takeOffAt, String duration, Price price)
{
this.originCode = originCode;
this.destinationCode = destinationCode;
this.takeOffAt = takeOffAt;
this.duration = duration;
this.price = price;
}
public override String ToString()
{
return $"BA {this.originCode} {this.destinationCode} {this.takeOffAt} {this.duration} {this.price}";
}
}
public class DuffelAirResponse
{
private String origin;
private String destination;
private String departureTime;
private String arrivalTime;
private String price;
public DuffelAirResponse(String origin, String destination, String departureTime, String arrivalTime, String price)
{
this.origin = origin;
this.destination = destination;
this.departureTime = departureTime;
this.arrivalTime = arrivalTime;
this.price = price;
}
public override String ToString()
{
return $"Duffel Air {this.origin} {this.destination} {this.departureTime} {this.arrivalTime} {this.price}";
}
}
public class VirginResponse
{
private String flights;
private String departureTime;
private String arrivalTime;
private String priceFractional;
private String currencyCode;
public VirginResponse(String flights, String departureTime, String arrivalTime, String priceFractional, String currencyCode)
{
this.flights = flights;
this.departureTime = departureTime;
this.arrivalTime = arrivalTime;
this.priceFractional = priceFractional;
this.currencyCode = currencyCode;
}
public override String ToString()
{
return $"Virgin {this.flights} {this.departureTime} {this.arrivalTime} {this.priceFractional} {this.currencyCode}";
}
}
public class Price
{
private String value;
private String code;
public Price(String value, String code)
{
this.value = value;
this.code = code;
}
public override String ToString()
{
return $"{this.value} {this.code}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment