Advertisement
calcpage

APCS2012_C3X5_Car.java

Oct 4th, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.38 KB | None | 0 0
  1. //Car.java  MrG 2012.1002
  2. public class Car
  3. {
  4.     private double tank;
  5.     private double efficiency;
  6.  
  7.     public Car(double efficiency)
  8.     {
  9.         tank = 0;
  10.         this.efficiency = efficiency;
  11.     }
  12.  
  13.     public double getGas()
  14.     {
  15.         return tank;
  16.     }
  17.  
  18.     public void addGas(double amount)
  19.     {
  20.         tank = tank + amount;
  21.     }
  22.  
  23.     public void drive(double miles)
  24.     {
  25.         tank = tank - miles/efficiency;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement