Question: / * * This class models a shuttle van. * / public class Van { / / Instance variables private int maxPassengers; private int currentPassengers;

/**
This class models a shuttle van.
*/
public class Van
{
// Instance variables
private int maxPassengers;
private int currentPassengers;
private double milesDriven;
/**
Constructs a van with a given capacity.
@param maxPassengers the maximum number of passengers that this
van can hold
*/
public Van(int maxPassengers)
{
this.maxPassengers = maxPassengers;
this.currentPassengers =0;
this.milesDriven =0;
}
/**
Boards passengers up to the capacity of this van.
@param boardingPassengers the number of passengers attempting
to board
*/
public void board(int boardingPassengers)
{
if (currentPassengers + boardingPassengers <= maxPassengers){
currentPassengers += boardingPassengers;
} else {
}
/**
Drives the van and discharges the passengers.
@param distance the distance driven
*/
public void drive(double distance)
{
milesDriven += distance;
currentPassengers =0;
}
/**
Gets the number of passengers in this van.
@return the number of passengers
*/
public int getPassengers()
{
return currentPassengers;
}
/**
Gets the number of miles that this van has driven.
@return the number of miles
*/
public double getMilesDriven()
{
return milesDriven;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!