Question: Intro to JAVA: _________________________ A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of
Intro to JAVA:
_________________________
A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers, but dont allow boarding if the van is full. Update the odometer when the van drives.
CODE:
/** This class models a shuttle van. */ public class Van { // Instance variables . . .
/** Constructs a van with a given capacity. @param maxPassengers the maximum number of passengers that this van can hold */ public Van(int maxPassengers) { . . . }
/** Boards passengers up to the capacity of this van. @param boardingPassengers the number of passengers attempting to board */ public void board(int boardingPassengers) { . . . }
/** Drives the van and discharges the passengers. @param distance the distance driven */ public void drive(double distance) { . . . }
/** Gets the number of passengers in this van. @return the number of passengers */ public int getPassengers() { . . . }
/** Gets the number of miles that this van has driven. @return the number of miles */ public double getMilesDriven() { . . . } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
