We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 67ddaae commit 27829a4Copy full SHA for 27829a4
src/org/launchcode/java/demos/testing/main/Car.java
@@ -76,6 +76,12 @@ public void drive(double miles)
76
{
77
//adjust fuel based on mpg and miles requested to drive
78
double maxDistance = this.milesPerGallon * this.gasTankLevel;
79
+ /**the double below uses some syntax called the ternary operator.
80
+ * if the value of miles is greater than the value of maxDistance,
81
+ * then milesAbleToTravel = maxDistance.
82
+ * otherwise, if miles is not greater than maxDistance,
83
+ * then milesAbleToTravel = miles
84
+ */
85
double milesAbleToTravel = miles > maxDistance ? maxDistance : miles;
86
double gallonsUsed = milesAbleToTravel / this.milesPerGallon;
87
this.gasTankLevel = this.gasTankLevel - gallonsUsed;
0 commit comments