Question
I need to update this C++ code per these instructions. I'm grateful for any help. Instructions: Here's my current code: #include #include #include using std::ofstream;
I need to update this C++ code per these instructions. I'm grateful for any help.
Instructions:
Here's my current code:
#include
using std::ofstream; using namespace std;
// globle constant variable hotel name const char* hotel_1 = "Bed n' Breakfast"; const char* hotel_2 = "Holiday Inn"; const char* hotel_3 = "Fairmont";
// class hotel class hotel { private: char hotel_name[3][20]; int room_type; int room_cost[6]; int selected_hotel; ofstream outdata; public: hotel(); //constructor ~hotel(); // Destructor void set_room_type(); // function to set room type int get_room_type(); // Function to get room type void set_room_cost(int room, int cost); // function to set room cost int get_room_cost(int r_type); // function to get room cost void print_price(); // It will print data on file as well as on the screen void select_hotel(); // function to select hotel };
/* constructor: setting data member as default value, opening a file to write */ hotel::hotel() { outdata.open("example2.dat"); // opens the file if( !outdata ) { // file couldn't be opened cerr
}
// CLASS DECLARATION (ABOVE CODE) SHOULD BE IN ".h "file . creat .c file using below code and include .h file in .c file.
/* Destructor:
it is closing the file which we have open */ hotel::~hotel() { outdata.close(); } void hotel::set_room_type(void) { cout > room_type; }
/* get_room_type: Function to get room type */ int hotel::get_room_type() { return room_type; }
// function to get room cost int hotel::get_room_cost(int r_type = -1) { cout
// function to set room cost void hotel::set_room_cost(int room, int cost) { room_cost[room_type] = cost; }
//It will print data on file as well as on the screen void hotel::print_price() { cout
// function to select hotel void hotel::select_hotel(void) { cout > selected_hotel; }
int main() { hotel h1; h1.select_hotel(); h1.get_room_cost(); h1.set_room_type(); cout
Use header files from now on to store declarations including classes which are normally in the global space. No declarations of any kind should be in the global space of aCPP file. Write a C++ Hotel APP program Design a Hotel Class which can hold information and show the cost of at least three hotel options and room choices for the brand.The class should have the following private member variables, hotel name, room type, room view and room cost. hotel name: 3 different hotel options (example Choice hotels brands Sleep Inn, Quality Inn, Comfort Suites.) room types: 2 queen, 2 double or king room view ocean or parking lot room cost dependent on 2 queen ocean view $300 2 queen parking lot view $200 . 2 double ocean view $250 2 double parking lot view $200 king ocean view $150 king parking lot view $100 Member functions should include mutators prefixed with the keyword "set" i.e. setQuantity and also include accessors prefixed with the keyword "get i.e. getQuantity. e set hotel name . get hotel name set room type . get room type set room type . get room view e set room cost . get room cost Display the following choices in a menu using a switch statement within a loop which continues until the user quits . Select hotel- 3 different hotel options . Select Room type and within this choice also select the room view. Show the costs associated with each choice Display to screen display to screen Print to file print to output file Quit- to exit the program (the condition in a loop should be strong enough to exit the loop) Create a function for each menu item containing the code to perform the menu selection except for Quit
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