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; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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; }

 

 
van.cpp
1 #include "van.h"
2 // Implement the member functions here
Transcribed Image Text:van.cpp 1 #include "van.h" 2 // Implement the member functions here
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education