Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created September 8, 2020 05:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssukhpinder/daf7fc8aae675ebfa289e289faeceb56 to your computer and use it in GitHub Desktop.
Save ssukhpinder/daf7fc8aae675ebfa289e289faeceb56 to your computer and use it in GitHub Desktop.
public static int OccupancyTypeTollFare(Object vehicleType) => vehicleType switch
{
Car { PassengerCount: 0 } => 100 + 10,
Car { PassengerCount: 1 } => 100,
Car { PassengerCount: 2 } => 100 - 10,
Car c => 100 - 20,
Taxi { Fare: 0 } => 100 + 10,
Taxi { Fare: 1 } => 100,
Taxi { Fare: 2 } => 100 - 10,
Taxi t => 100 - 20,
Bus b when ((double)b.RidersCount / (double)b.Capacity) < 0.50 => 150 + 30,
Bus b when ((double)b.RidersCount / (double)b.Capacity) > 0.90 => 150 - 40,
Bus b => 150,
DeliveryTruck t when (t.Weight > 5000) => 200 + 100,
DeliveryTruck t when (t.Weight < 3000) => 200 - 20,
DeliveryTruck t => 200,
null => 0,
{ } => 0,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment