A shuttle van picks up passengers and drives them to a destination, where they leave the van. Store the names of the boarding passengers. Don't allow boarding if the van is full. Update the odometer when the van drives. Complete the following file: (image) ----------- Use the following files: van.h #ifndef VAN_H #define VAN_H #include #include using namespace std; /** This class models a shuttle van. */ class Van { public: /** Constructs a van with a given capacity. @param max_passengers the maximum number of passengers that this van can hold */ Van(int max_passengers); /** Boards a passengers up to the capacity of this van. @param name the name of the passenger attempting to board */ void board(string name); /** Drives the van and discharges the passengers. @param distance the distance driven */ void drive(double distance); /** Gets the passengers in this van. @return the number of passengers */ vector get_passengers() const; /** Gets the number of miles that this van has driven. @return the number of miles */ double get_miles_driven() const; private: double miles_driven; vector passengers; int capacity; }; #endif van_Tester.cpp #include using namespace std; #include "van.h" void print(vector v); int main() { Van van1(8); van1.board("Fred"); van1.board("Ann"); van1.board("Lee"); print(van1.get_passengers()); cout << "Expected: [Fred, Ann, Lee]" << endl; van1.board("Tim"); van1.board("Joe"); van1.board("Pat"); van1.board("May"); van1.board("Sue"); van1.board("Sally"); print(van1.get_passengers()); cout << "Expected: [Fred, Ann, Lee, Tim, Joe, Pat, May, Sue]" << endl; van1.drive(10); print(van1.get_passengers()); cout << "Expected: []" << endl; cout << van1.get_miles_driven() << endl; cout << "Expected: 10" << endl; van1.board("Sally"); print(van1.get_passengers()); cout << "Expected: [Sally]" << endl; van1.drive(12); print(van1.get_passengers()); cout << "Expected: []" << endl; cout << van1.get_miles_driven() << endl; cout << "Expected: 22" << endl; return 0; } void print(vector v) { cout << "["; if (v.size() > 0) { cout << v[0]; for (int i = 1; i < v.size(); i++) { cout << ", " << v[i]; } } cout << "]" << endl; }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

A shuttle van picks up passengers and drives them to a destination, where they leave the van. Store the names of the boarding passengers. Don't allow boarding if the van is full. Update the odometer when the van drives.

Complete the following file: (image)

-----------

Use the following files:

van.h

#ifndef VAN_H #define VAN_H #include <string> #include <vector> using namespace std; /** This class models a shuttle van. */ class Van { public: /** Constructs a van with a given capacity. @param max_passengers the maximum number of passengers that this van can hold */ Van(int max_passengers); /** Boards a passengers up to the capacity of this van. @param name the name of the passenger attempting to board */ void board(string name); /** Drives the van and discharges the passengers. @param distance the distance driven */ void drive(double distance); /** Gets the passengers in this van. @return the number of passengers */ vector<string> get_passengers() const; /** Gets the number of miles that this van has driven. @return the number of miles */ double get_miles_driven() const; private: double miles_driven; vector<string> passengers; int capacity; }; #endif

van_Tester.cpp

#include <iostream> using namespace std; #include "van.h" void print(vector<string> v); int main() { Van van1(8); van1.board("Fred"); van1.board("Ann"); van1.board("Lee"); print(van1.get_passengers()); cout << "Expected: [Fred, Ann, Lee]" << endl; van1.board("Tim"); van1.board("Joe"); van1.board("Pat"); van1.board("May"); van1.board("Sue"); van1.board("Sally"); print(van1.get_passengers()); cout << "Expected: [Fred, Ann, Lee, Tim, Joe, Pat, May, Sue]" << endl; van1.drive(10); print(van1.get_passengers()); cout << "Expected: []" << endl; cout << van1.get_miles_driven() << endl; cout << "Expected: 10" << endl; van1.board("Sally"); print(van1.get_passengers()); cout << "Expected: [Sally]" << endl; van1.drive(12); print(van1.get_passengers()); cout << "Expected: []" << endl; cout << van1.get_miles_driven() << endl; cout << "Expected: 22" << endl; return 0; } void print(vector<string> v) { cout << "["; if (v.size() > 0) { cout << v[0]; for (int i = 1; i < v.size(); i++) { cout << ", " << v[i]; } } cout << "]" << endl; }

C++ please

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Graphical User Interface
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning