//This class is used to calculates fuel efficiency
class Vehicle {
private int passengers; //number of passengers
private int fuelcap; //fuel capacity in gallons
private int mpg; // fuel consumption in miles per gallon
//This is a constructor for Vehicle.
Vehicle (int p, int f, int m) {
passengers = p;
fuelcap = f;
mpg = m;
}
//Return the range.
int range() {
return mpg * fuelcap;
}
//Compute fuel needed for a given distance.
double fuelneeded(int miles){
return (double) miles/mpg;
}
//These are the access methods I was talking about.
//The book says they are for instance variables.
int getPassengers() {return passengers;}
void setPassengers(int p) {passengers = p;}
int getFuelcap () {return fuelcap;}
void getFuelcap (int f) {fuelcap = f;}
int getMpg() {return mpg;}
void getMpg (int m) { mpg = m;}
}