BidAdvisor class

Decides whether a bid is good for the driver.

The mistake that ruins drivers

An €8 ride looks better than a €5 one. But if the first is 12 minutes away and the second 2, and both take 10 minutes of trip:

Ride A Ride B
Amount €8.00 €5.00
Getting to the pickup 5.0 km · 12 min 0.8 km · 2 min
Trip 6.0 km · 10 min 4.2 km · 10 min
Total kilometers 11.0 5.0
Cost at €0.20/km €2.20 €1.00
Net €5.80 €4.00
Time busy 22 min 12 min
Net per hour €15.82/h €20.00/h

The ride that pays less leaves 26 % more per hour. This class does that math, and those numbers are exactly the ones the test suite checks.

Annotations

Constructors

BidAdvisor({required DriverEconomics economics, required int minorUnitDigits, required String currency})
Creates an advisor for the driver.
const

Properties

currency → String
The ISO 4217 currency code.
final
economics → DriverEconomics
The driver's cost model.
final
hashCode → int
The hash code for this object.
no setterinherited
minorUnitDigits → int
How many decimal places the currency has.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

breakEvenFare({required double deadheadMeters, required Duration deadheadDuration, required double tripMeters, required Duration tripDuration}) → int
The minimum amount at which this ride reaches the hourly target.
evaluate({required int fare, required double deadheadMeters, required Duration deadheadDuration, required double tripMeters, required Duration tripDuration}) → BidEvaluation
Evaluates a specific ride.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited