Hi,
my goal is to implement a program (in OO style) for cruise booking system that can accept and maintain customers’ reservation. Whenever a customer visits, that program should show him/her the current availablility of cabins. A customer can choose any available cabin with specified level (0 – 2, down to up), row (0-3, left to right) and cabin number (0-12, front to back). Once a cabin is reserved, it should be marked as unavailable.
My program should be able to read from a text file with the information of cabin distribution and availability. It should be able to save the information of cabin distribution and availability to a text file.
I've created a main function that takes information from customers and output required information.
However, my problem is that I have too many errors from this code. Can you tell me what is wrong with it? I tried to look at these errors, I have absolutely no idea how to resolve them. (I am a beginning of C++)
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cstring>
#include<iomanip>
using namespace std;
const int MaxLvl = 3;
const int MaxRow = 4;
const int MaxCab = 12;
const int MaxRom = 156;
class cruise {
private:
char cabins[MaxCab][MaxRow][MaxLvl]
//bool validate(char);
int L3, R4, C12;
public:
void readInformation();
void writeInformation();
void reserveCabin();
void showAvailability(int, int, int, int);
};
void cruise :: readInformation()
{
cout << "Cabin Informations" << endl;
ifstream file;
file.open ("cInformation.txt", ifstream::in);
while (file.good())
cout << (char) file.get();
file.close();
cout << "Close the file." << endl;
}
void cruise :: writeInformation();
{
ifstream file;
file.open ("cInformation.txt");
if(!file)
{
cout << "Error! The file cannot open.";
exit(1);
}
for (int l = 0; L3 < MaxLvl; L3++)
{
for (int C12 = 0; C12 < MaxCab; C12++)
{
for (int R4 = 0; R4 < MaxRow; R4++)
}
}
}
file.close();
}
void cruise :: reserveCabin()
{
string fullName;
char YN;
cout << "Welcome to our Queen Cruise. Please register to receive a ticket." << endl;
do {
cout << "Full name: ";
cin >> fullName;
cout << "Please book available cabin" << endl;
cout << "There are three levels in our cruise. Which level would you like to book?" << endl;
cout << "Enter 1 for the ground level, 2 for the second level and 3 for the top level. Please enter 1-3: ";
cin >> L3;
cout << "Which row would you like to book? 1 from left and 4 from right. Enter 1-4: ";
cin >> R4;
cout << "Which cabin would you like to take (1 to 12)? ";
cin >> C12;
if (cabin[L3][R4][C12] != 'X')
{
cabin[L3][R4][C12] != 'X';
}
else
cout << "Unfortunately, the cabin is unavailable." << endl;
cout << "Please book another cabin (Y/N): ";
cin >> YN;
}
while (YN == 'y' || YN == 'Y');
}
void cruise :: showAvailability(int l, int r, int c, int o)
{
if (l > 0 && l <= MaxLvl && r > 0 && r <= MaxRow && c > 0 && c <= MaxCab && o = 0 && o <= MaxRom && cabins[l][r][c][o] != 'X') {
return true;
}
else {
return false;
}
}