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 Vanint maxPassengers
this.maxPassengers maxPassengers;
this.currentPassengers ;
this.milesDriven ;
Boards passengers up to the capacity of this van.
@param boardingPassengers the number of passengers attempting
to board
public void boardint boardingPassengers
if currentPassengers boardingPassengers maxPassengers
currentPassengers boardingPassengers;
else
Drives the van and discharges the passengers.
@param distance the distance driven
public void drivedouble distance
milesDriven distance;
currentPassengers ;
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
