/**
* @author cdodge
* 1-17-2017
* This class represents a car
*/
public class Vehicle {
// The vehicle class has two fields/instance variable and they are:
private String make;
private int milesPerGallon;
// The following is the default constructor
public Vehicle() {
}
// The following constructor accepts two parameters, carMake and mpg.
// The use of multiple constructors is known as overloading
public Vehicle(String carMake, int mpg) {
make = carMake;
milesPerGallon = mpg;
}
// This constructor uses the same variable names as the object
// this.variable names indicates the variable belongs to the object and is not a parameter
public Vehicle(int milesPerGallon, String make) {
this.make = make;
this.milesPerGallon = milesPerGallon;
}
// mutator/setter methods
public void setMake(String m){
make = m;
}
public void setMilesPerGallon(int mpg){
milesPerGallon = mpg;
}
// accessor/getter methods:
public String getMake(){
return make;
}
public int getMilesPerGallon(){
return milesPerGallon;
}
}