Untitled

 avatar
unknown
plain_text
a year ago
1.1 kB
8
Indexable
public class CarTester
{
    public static void main(String[] args)
    {
        // Create a Car object
        Car compact = new Car("S3", 8);
        
        // Print out the model
        System.out.println("Model: " + compact.getModel());
        
        // Print out the fuelLevel
        System.out.println("Gallons Left: " + compact.getFuelLevel());
        
        // Print how many miles are left with 23 mpg
        System.out.println("Miles Left: " + compact.milesLeft(23));
        
        // Print the object
        System.out.println(compact);
        
        // Create an ElectricCar object
        ElectricCar zappy = new ElectricCar("BattMax", 73);
        
        // Print out the model
        System.out.println("Model: " + zappy.getModel());
        
        // Print out the fuelLevel
        System.out.println("Battery Level: " + zappy.getFuelLevel());
        
        // Print how many miles are left with 400 miles per charge
        System.out.println("Miles Left: " + zappy.milesLeft(400));
        
        // Print the object
        System.out.println(zappy);
    }
}
Editor is loading...
Leave a Comment