Question
InStatePark.cpp: Implement the getter functionsgetParkName(),getEntranceFee(), andgetTrailMiles(). Implement the functionaddCamper(), which takes in a pointer to aPassport object as a parameter and adds it to the
- InStatePark.cpp:
- Implement the getter functionsgetParkName(),getEntranceFee(), andgetTrailMiles().
- Implement the functionaddCamper(), which takes in a pointer to aPassport object as a parameter and adds it to the end of the vectorcamperLog.
- In my current StatePark.cpp, addCamper function works properly, but others do not.
StatePark.cpp:
#include "Passport.h"
using std::string, std::vector;
// Mandatory // Constructor for StatePark class // TODO(student): implement constructor using member initializer list StatePark::StatePark(std::string parkName, double entranceFee, double trailMiles) : parkName(), entranceFee(), trailMiles(), camperLog({}) {}
// Mandatory // Getter for data member parkName string StatePark::getParkName() { // TODO(student): implement getter // return the parkName return parkName; }
// Mandatory // Getter for data member entranceFee double StatePark::getEntranceFee() { // TODO(student): implement getter return entranceFee; }
// Mandatory // Getter for data member trailMiles double StatePark::getTrailMiles() { // TODO(student): implement getter return trailMiles; }
// Mandatory // Adds a camper (represented by Passport object) to data member camperLog void StatePark::addCamper(Passport* camper) { INFO(camper) // TODO(student): implement function camperLog.push_back(camper); return; }
StatePark.h:
# ifndef _STATEPARK_H # define _STATEPARK_H
# include
# define INFO(X) std::cout << "[INFO] ("<<__FUNCTION__<<":"<<__LINE__<<") " << #X << " = " << X << std::endl;
class Passport;
class StatePark { private: std::string parkName; double entranceFee; double trailMiles; std::vector
Passport* getCamperAt(unsigned int i) { return camperLog.at(i); } };
# endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started