Guest User

Untitled

a guest
Jun 24th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public class Car extends CarTester
  2. {
  3. private double milesDriven;
  4. private double gasTank;
  5.  
  6. private double getGasInTank;
  7. private double getMilesDriven;
  8. /**
  9. Constructs a car with a given fuel efficiency.
  10. @param anEfficiency the fuel efficiency of the car
  11. */
  12. public Car(double anEfficiency)
  13. {
  14. }
  15.  
  16. /** Adds gas to the teank.
  17. @param amount the amount of fuel to add
  18. */
  19. public void addGas(double amount)
  20. {
  21. gasTank = amount + amount + amount;
  22.  
  23. }
  24.  
  25. /**
  26. Drives a certain amount, consuming gas.
  27. @param distance the distance driven
  28. */
  29. public void drive(double distance)
  30. {
  31. milesDriven = distance + milesDriven;
  32. }
  33.  
  34. /**
  35. Gets the amount of gas left in the tank.
  36. @return the amount of gas
  37. */
  38. public double getGasInTank()
  39. {
  40. getGasInTank = gasTank - (milesDriven/50);
  41. return getGasInTank;
  42. }
  43.  
  44. /**
  45. Gets the total miles driven by this car.
  46. @return the miles driven
  47. */
  48. public double getMilesDriven()
  49. {
  50. return milesDriven;
  51. }
  52. }
Add Comment
Please, Sign In to add comment