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 don't allow boarding if the van is full. Update the odometer when the van drives. Van.java 1 /** This class models a shuttle van. */ 4 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) { 10 11 12 13 14 15 16 17 18 19 20 21 55 } /** Boards passengers up to the capacity of this van. @param boardingPassengers the number of passengers attempting to board */ public void board(int boardingPassengers) { 25 26 27 28 } /** Drives the van and discharges the passengers. @param distance the distance driven */ public void drive(double distance) { } 38 40 41 42 43 /** Gets the number of passengers in this van. @return the number of passengers */ public int getPassengers() { 44 45 46 47 48 49 50 51 /** Gets the number of miles that this van has driven. @return the number of miles */ public double getMilesDriven(O 53 54 55 } VanTester.java 1 public class VanTester 2 { public static void main(String[) args) { Van vanl = new Van(8); vanl.board (3); System.out.println(van1.getPassengers()); System.out.println("Expected: 3"); vani, boardien System.out.println(van1.getPassengers()); System.out. - out.println("Expected: 8"); van1.drive(10); System.out.println(vanl.getPassengers()); ystem. out.println("Expected: 0"); . out.println(van1.getMilesDriven()); System.out. System.out.println("Expected: 10"); van1. board(6) System.out.println(van1.getPassengers()); System.out.println("Expected: 6"); van1.drive(12); System.out.println(van1.getPassengers()); System.out.println("Expected: 0"); System.out.println(van1.getMilesDriven()); System.out.println("Expected: 22"); } 25 26

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter1: Creating Java Programs
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question
100%
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 don't allow boarding if the van is full. Update the odometer when the van drives.
Van.java
1 /**
This class models a shuttle van.
*/
4 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)
{
10
11
12
13
14
15
16
17
18
19
20
21
55
}
/**
Boards passengers up to the capacity of this van.
@param boardingPassengers the number of passengers attempting
to board
*/
public void board(int boardingPassengers)
{
25
26
27
28
}
/**
Drives the van and discharges the passengers.
@param distance the distance driven
*/
public void drive(double distance)
{
}
38
40
41
42
43
/**
Gets the number of passengers in this van.
@return the number of passengers
*/
public int getPassengers()
{
44
45
46
47
48
49
50
51
/**
Gets the number of miles that this van has driven.
@return the number of miles
*/
public double getMilesDriven(O
53
54
55 }
VanTester.java
1 public class VanTester
2 {
public static void main(String[) args)
{
Van vanl = new Van(8);
vanl.board (3);
System.out.println(van1.getPassengers());
System.out.println("Expected: 3");
vani, boardien
System.out.println(van1.getPassengers());
System.out.
- out.println("Expected: 8");
van1.drive(10);
System.out.println(vanl.getPassengers());
ystem. out.println("Expected: 0");
. out.println(van1.getMilesDriven());
System.out.
System.out.println("Expected: 10");
van1. board(6)
System.out.println(van1.getPassengers());
System.out.println("Expected: 6");
van1.drive(12);
System.out.println(van1.getPassengers());
System.out.println("Expected: 0");
System.out.println(van1.getMilesDriven());
System.out.println("Expected: 22");
}
25
26
Transcribed Image Text: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 don't allow boarding if the van is full. Update the odometer when the van drives. Van.java 1 /** This class models a shuttle van. */ 4 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) { 10 11 12 13 14 15 16 17 18 19 20 21 55 } /** Boards passengers up to the capacity of this van. @param boardingPassengers the number of passengers attempting to board */ public void board(int boardingPassengers) { 25 26 27 28 } /** Drives the van and discharges the passengers. @param distance the distance driven */ public void drive(double distance) { } 38 40 41 42 43 /** Gets the number of passengers in this van. @return the number of passengers */ public int getPassengers() { 44 45 46 47 48 49 50 51 /** Gets the number of miles that this van has driven. @return the number of miles */ public double getMilesDriven(O 53 54 55 } VanTester.java 1 public class VanTester 2 { public static void main(String[) args) { Van vanl = new Van(8); vanl.board (3); System.out.println(van1.getPassengers()); System.out.println("Expected: 3"); vani, boardien System.out.println(van1.getPassengers()); System.out. - out.println("Expected: 8"); van1.drive(10); System.out.println(vanl.getPassengers()); ystem. out.println("Expected: 0"); . out.println(van1.getMilesDriven()); System.out. System.out.println("Expected: 10"); van1. board(6) System.out.println(van1.getPassengers()); System.out.println("Expected: 6"); van1.drive(12); System.out.println(van1.getPassengers()); System.out.println("Expected: 0"); System.out.println(van1.getMilesDriven()); System.out.println("Expected: 22"); } 25 26
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT