Hi James. Welcome to the Ranch!
OK, I'd suggest stepping away from the code for a moment, and making sure you understand what's required.
there should be a method drive(double miles) which simulates driving the car a specified distance. The drive() method should adjust the fuel level by the amount of fuel used, adjust the odometer by the amount of miles driven, and it should return the number of miles driven, which may be less than the number of miles specified if there is not enough fuel.
The car has got two properties that you're keeping track of: the distance travelled and the fuel level. You also know the fuel efficiency (miles per gallon).
So, if your current distance travelled is
x, your current fuel level is
y, and try to drive
z miles:
- how much fuel will you use?
- how much fuel will you have left?
- what will be your total distance travelled?
- and if you try and drive too far, what distance will you travel before you run out of fuel?
Make sure you know how to calculate these using a pencil and paper. Once you completely understand that,
then try and write the equivalent code.