Question: please help fix this code so the HotelReservation and Reservation use the dates entered in the main, also so that the default date 0 1
please help fix this code so the HotelReservation and Reservation use the dates entered in the main, also so that the default date january st is zero days from january first when its printed
datecpp
#include "Date.h
using namespace std;
#include
#include
const unsigned Date::daysInMonth;
Date::Date : days
unsigned Date::calculateDaysint month, int day const
unsigned totalDays ;
forint i ; i month; i
totalDays getDaysInMonthi;
ifmonth && day
totalDays day ;
return totalDays;
unsigned Date::getDaysInMonthint month const
return month && month daysInMonthmonth : ;
void Date::getMonthDayint& month, int& day const
unsigned totalDays days;
month ;
while totalDays getDaysInMonthmonth
totalDays getDaysInMonthmonth;
month;
day totalDays;
ostream& operatorostream& os const Date& date
int month, day;
date.getMonthDaymonth day;
os setfill setw month setw day;
os date.days days from january ;
return os;
Date& Date::operatorconst string& dateStr
sizet pos dateStr.find;
int month stoidateStrsubstr pos;
int day stoidateStrsubstrpos ;
int totalDays day ;
for int i ; i month; i
totalDays Date::daysInMonthi;
days totalDays;
return this;
bool Date::operatorconst string& dateStr const
Date otherDate;
otherDate dateStr;
return daysotherDate.days;
bool Date::operatorconst string& dateStr const
Date otherDate;
otherDate dateStr;
return days otherDate.days;
dateh
#ifndef DATEH
#define DATEH
#include
#include
using namespace std;
class Date
private:
unsigned days;
static const unsigned daysInMonth;
unsigned calculateDaysint month, int day const;
unsigned getDaysInMonthint month const;
void getMonthDayint& month, int& day const;
public:
Date;
unsigned getDays constreturn days;
friend std::ostream& operatorstd::ostream& os const Date& date;
Date& operatorconst std::string& dateStr;
bool operatorconst std::string& dateStr const;
bool operatorconst std::string& dateStr const;
;
#endif
Reservationh
#ifndef RESERVATIONH
#define RESERVATIONH
#include "Date.h
#include
class Reservation
private:
std::string reservationName;
Date reservationDate;
float reservationFee;
protected:
bool ishighseason;
public:
Reservationconst string& reservationName, int day, int month, float fee ;
string tostring const;
double calculatecost const;
;
#endif
Reservationcpp
#include "Reservation.h
#include "Date.h
#include
#include
#include
Reservation::Reservationconst string& reservationName, int day, int month, float fee : reservationNamereservationNamereservationFeefee
string
string Reservation::tostring const
stringstream ss;
ss reservationName on reservationDate
Fee: $ fixed setprecision reservationFee;
return ssstr;
calc cost
double Reservation::calculatecost const
double cost reservationFee;
ifishighseason true
return reservationFee ;
else
return reservationFee;
HotelReservationh
#ifndef HOTELRESERVATIONH
#define HOTELRESERVATIONH
#include "Date.h
#include "Reservation.h
#include
class HotelReservation : public Reservation
private:
string hotelName;
double costPerNight;
int nights;
public:
HotelReservationconst string& reservationName, int day, int month, const string& hotelName, double costPerNight int nights;
std::string tostring const;
double calculatecost const;
;
#endif
HotelReservationcpp
#include "HotelReservation.h
#include
#include "Reservation.h
#include "Date.h
#include
HotelReservation::HotelReservationconst string& reservationName, int day, int month, const string& hotelName, double costPerNight int nights : ReservationreservationName day, month hotelNamehotelName costPerNightcostPerNight nightsnights
string HotelReservation::tostring const
string reservationDetails "Hotel Reservation Details:
;
reservationDetails Reservation::tostring;
reservationDetails for std::tostringnights nights at hotelName;
double totalCost calculatecost;
return reservationDetails;
double HotelReservation::calculatecost const
double totalCost costPerNight nights;
ifishighseason truetotalCost ;
return totalCost
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
