Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Automobile color, brand, model, and license plate number of the cars parked in the parking lot. Automobile objects are stable, meaning their attributes are specified

Automobile color, brand, model, and license plate number of the cars parked in the parking lot. Automobile objects are stable, meaning their attributes are specified at construction and they dont change thereafter. no default constructor. ClaimCheck a unique claim check number and the automobile associated with the claim. Students are issued a claim check when dropping off their vehicle, and redeem their vehicle with the claim check when picking up. Two claim checks are equal if they have equal claim check numbers. An automobile is associated with a claim check and a unique claim check number is generated at construction. There is no default constructor. Once a claim check is created it cannot be altered. The claim check number and the associated automobile may be queried from a claim check. ParkingLot Parking lots support dropping off and picking up automobiles. A student drops off an automobile and receives a claim check. A student provides a claim check and picks up an automobile. Traffic flow is enforced with one-way traffic spikes, so you cannot back up. Once you enter the aisle you must pull all the way through, if nobody is parked in front of you. When picking up, vehicles are removed one at a time from the front and added to the back until the desired car is found as illustrated below. If the claimed vehicle is not found in the parking lot, you can either throw an std::invalid_argument (strongly recommended but not required) or print an error message.

*************************automobile.cpp

#include #include

#include "Automobile.hpp" ** Member function definitions Automobile::Automobile( const std::string & color, const std::string & brand, const std::string & model, const std::string & plateNumber ) : color_(color), brand_(brand), model_(model), plateNumber_(plateNumber) {} ** Non-member function definitions bool operator==( const Automobile& lhs, const Automobile& rhs ) { /// To be completed: Return true if each attribute of the left hand side (lhs) is equal to the right hand side (rhs) }

bool operator!=( const Automobile& lhs, const Automobile& rhs ) { return !( lhs == rhs ); }

std::ostream & operator<<( std::ostream& stream, const Automobile& vehicle ) { /// To be completed: Insert the vehicle's color, brand, model, and license plate number into the stream, then return the stream }

**************************************automobile.hpp

#pragma once #include #include class Automobile { friend bool operator==( const Automobile& lhs, const Automobile& rhs ); friend std::ostream & operator<<( std::ostream& stream, const Automobile& vehicle );

private: std::string color_; std::string brand_; std::string model_; std::string plateNumber_;

public: Automobile( const std::string & color, const std::string & brand, const std::string & model, const std::string & plateNumber ); };

bool operator!=( const Automobile& lhs, const Automobile& rhs );

*********************************ClaimCheck.cpp

#include

#include "Automobile.hpp" #include "ClaimCheck.hpp" ** Class attributes size_t ClaimCheck::nextAvailableClaimNumber = 100; ** Member function definitions ClaimCheck::ClaimCheck( const Automobile & vehicle ) : vehicle_(vehicle), /// To be completed: Initialize claimNumber_ to the next available claim number while & post-incrementing the next available claim number {}

Automobile ClaimCheck::vehicle() const { return vehicle_; }

size_t ClaimCheck::claimNumber() const { return claimNumber_; } ** Non-member function definitions bool operator==( const ClaimCheck & lhs, const ClaimCheck & rhs ) { /// To be completed: Two claim checks are equal if they have equal claim check numbers. }

bool operator!=( const ClaimCheck & lhs, const ClaimCheck & rhs ) { return ! (lhs == rhs); }

std::ostream & operator<<( std::ostream & stream, const ClaimCheck & ticket ) { /// To be completed: insert the ticket's vehicle and claim number into the stream then return the stream }

********************************ClaimCheck.hpp

#pragma once #include

#include "Automobile.hpp"

class ClaimCheck { friend bool operator==( const ClaimCheck & lhs, const ClaimCheck & rhs ); friend std::ostream & operator<<( std::ostream & stream, const ClaimCheck & ticket );

private: const Automobile vehicle_; const size_t claimNumber_; static size_t nextAvailableClaimNumber;

public: ClaimCheck( const Automobile & vehicle );

Automobile vehicle () const; size_t claimNumber() const; };

bool operator!=( const ClaimCheck & lhs, const ClaimCheck & rhs );

**************************************ParkingLot.cpp

#include #include #include

#include "ClaimCheck.hpp" #include "ParkingLot.hpp" ** ParkingLot Member function definitions ClaimCheck ParkingLot::dropOff( const Automobile& vehicle ) { /// To be completed: Create a claim check called ticket passing in the vehicle

/// To be completed: Add the vehicle and the ticket's claim number to the collection of parked cars. Hint: Create a ParkedCar and set its vehicle and claim number attributes, then push it on to the stack.

return ticket; } Automobile ParkingLot::pickUp( const ClaimCheck& ticket ) { /// To be completed: Move cars from the front of the queue to the back of the queue until youfind the one you're looking for or until you looked at them all. Hint: The vehicle you're looking for has a ticket claim number that matches the parked car's claim number.

/// To be completed: If you reach this point, the vehicle you're looking for wasn't in the parking lot. Optional: Throw an invalid argument exception (highly recommended but not required). Otherwise print out an error message and return the ticket's vehicle. } size_t ParkingLot::quantity() { /// To be completed: Return the number of parked cars that are currently in the parking lot }

*****************************ParkingLot.hpp

#pragma once #include

#include "ClaimCheck.hpp" #include "Automobile.hpp"

struct ParkedCar { Automobile vehicle_; size_t claimNumber_; };

class ParkingLot { private: std::queue parkedCars_; // aisles closed on one end

public: ClaimCheck dropOff( const Automobile& vehicle ); Automobile pickUp ( const ClaimCheck& ticket );

size_t quantity(); };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions