SHARE
TWEET

APCS2012_C3X5_CarDriver.java

calcpage Oct 4th, 2012 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. CarDriver.java          MrG             2012.1002
  3. purpose:        simulating gas consumption in my car
  4. required files: CarDriver.java                  main class
  5.                 Car.java                        derived class
  6. translator:     javac CarDriver.java
  7. interpreter:    java CarDriver
  8. */
  9.  
  10. //main class
  11. public class CarDriver
  12. {
  13.         public static void main(String[] args)
  14.         {
  15.                 Car bmw = new Car(50);
  16.                 System.out.println("gas left = " + bmw.getGas() + " gallons");
  17.                 bmw.addGas(10);
  18.                 System.out.println("gas left = " + bmw.getGas() + " gallons");
  19.                 bmw.drive(20);
  20.                 System.out.println("gas left = " + bmw.getGas() + " gallons");
  21.         }
  22. }
RAW Paste Data
Top