SHARE
TWEET

APCS2012_C3X5_Car.java

calcpage Oct 4th, 2012 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top