Here are my errors.
Code:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(268,5): error MSB6006: "link.exe" exited with code 1120.1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Room::isSmoking(int)" (?isSmoking@Room@@QAE_NH@Z) referenced in function "void __cdecl roomStatus(class Room,int)" (?roomStatus@@YAXVRoom@@H@Z)
1>C:\Users\Trey\documents\visual studio 2010\Projects\OOP Program 1\Debug\OOP Program 1.exe : fatal error LNK1120: 1 unresolved externals
Here are my three files. Main is still in progress.
room.h
Code:
#include "Customer.h"
#pragma once
class Room
{
// Class customer and the data types below will not compile unless
// publically accessible.
public:
Room(void);
~Room(void);
Customer customer;
double bill;
int occNum;
int nights;
// Member functions, publically accessible.
bool isSmoking (int n);
double getBill(int nights, int occNum);
int getNights();
void setNights(int days);
int getOccNum();
void setOccNum(int ppl);
void assignCustomer(Customer c);
void clearRoom();
};
room.cpp
Code:
#include "Room.h"
Room::Room(void)
{
};
Room::~Room(void)
{
};
bool IsSmoking (int n)
{
return (n <= 20);
}
double Room::getBill(int nights, int occNum)
{
double money = 1.00;
int x = (occNum-1)*10;
int y = (60+occNum)*nights;
money = money*y;
return money;
};
int Room::getNights()
{
return nights;
};
void Room::setNights(int days)
{
nights = days;
return;
};
int Room::getOccNum()
{
return occNum;
};
void Room::setOccNum(int ppl)
{
occNum = ppl;
return;
};
void Room::assignCustomer(Customer c)
{
customer.setName(c.getName());
customer.setCCNum(c.getCCNum());
return;
};
void Room::clearRoom()
{
occNum = 0;
nights = 0;
customer.setName("");
customer.setCCNum("");
return;
}
main.cpp
Code:
// Trey Brumley// Shujing Zhang
// 1 October 2013
// Stringfellow - 2143
// Project 1 - Hotel Program
// =========================
#include "Hotel.h"
#include <iostream>
#include <string>
using namespace std;
void assigmSmoking(Room r, int n);
void checkIn(Room r);
void unoccupiedRooms(Hotel h);
void roomStatus(Room r, int n);
void modifyRoom(Room r);
void hotelOccupancy(Hotel ho);
void checkOut(Room r);
int main (int argc, char *argv[])
{
Hotel hotel;
char ch;
int roomNum;
cout << "Please enter one of the following letters to perform a function." << endl;
cout << "To check a customer into a room, enter C (for Check-in)." << endl;
cout << "To check how many rooms are occupied, enter O (for Occupancy)." << endl;
cout << "To check the status of a room, enter S (for Status)." << endl;
cout << "To modify room data (e.g. change nights, add or subtract occupants), enter M (for Modify)." << endl;
cout << "To find an open room (smoking and non will be indicated), enter F (for Find)." << endl;
cout << "To calculate a room's current bill, enter B (for Bill)." << endl;
cout << "To check a customer out of a room, enter E (for Exit)." << endl;
cout << "To quit this program, enter Q (for Quit)." << endl;
cout << "Please enter your command letter now: ";
cin >> ch;
ch = toupper(ch);
while (ch != 'Q')
{
switch (ch)
{
case 'C':
cout << "Which room is being checked in to? ";
cin >> roomNum;
checkIn(hotel.room[roomNum]);
break;
case 'O':
hotelOccupancy(hotel);
break;
case 'S':
cout << "Please enter a room number to check: ";
cin >> roomNum;
roomStatus(hotel.room[roomNum], roomNum);
break;
case 'M':
cout << "Please enter a room number to modify: ";
cin >> roomNum;
modifyRoom(hotel.room[roomNum]);
break;
case 'B':
cout << "Which room is being calculated? ";
cin >> roomNum;
hotel.room[roomNum].getBill(hotel.room[roomNum].nights, hotel.room[roomNum].occNum);
break;
case 'E':
cout << "Which room is being checked out? ";
cin >> roomNum;
break;
case 'F':
unoccupiedRooms(hotel);
break;
default:
cout << "ERROR: Invalid operation." << endl;
break;
}
cout << "Please enter a command (to review the list, return to the top of this list): ";
cin >> ch;
ch = toupper(ch);
}
cout << "Thank-you for using this program! Have a nice day!" << endl;
system("pause");
return 0;
}
void checkIn (Room r)
{
string name, CCnum;
cout << "Please enter the name of the customer checking in: ";
cin >> name;
cout << "Please enter the credit card number: ";
cin >> CCnum;
r.customer.setCCNum(CCnum);
r.customer.setName(name);
return;
}
// Finds unoccupied one smoking and one nonsmoking room.
void unoccupiedRooms(Hotel h)
{
int s = 0;
int n = 0;
int x = 1;
//Checks all smoking rooms, finds the lowest-numbered unoccupied room, and
//prints the result.
while (s == 0 && x <= 20)
{
if (h.room[x].occNum == 0)
x++;
else
s = x;
}
if (s == 0)
cout << "There are no smoking rooms available." << endl;
else
cout << "Smoking Room " << s << " is available." << endl;
// Sets x to 21 and checks all non-smoking rooms the same.
x = 21;
while (n == 0 && x <= 100)
{
if (h.room[x].occNum == 0)
x++;
else
n = x;
}
if (n == 0)
cout << "There are no non-smoking rooms available." << endl;
else
cout << "Non-Smoking Room " << n << " is available." << endl;
return;
}
void roomStatus (Room r, int n)
{
int x = r.getOccNum();
if (x != 0)
{
if (r.isSmoking(n))
cout << "Smoking: YES." << endl;
else
cout << "Smoking: NO." << endl;
cout << "Customer: " << r.customer.getName() << endl;
cout << "Occupants: " << r.getOccNum() << endl;
cout << "Nights occupied: " << r.getNights() << endl;
}
else
cout << "This room is not occupied." << endl;
return;
}
void modifyRoom (Room r)
{
return;
}
//Checks how many rooms are not occupied.
void hotelOccupancy (Hotel ho)
{
int i=0;
int j=0;
int x = 0;
//Checks all non-smoking rooms. If a room has no occupants, the counter adds one.
//Otherwise, it goes to the next room. At the end, it prints out its findings.
while (x <= 20)
{
if (ho.room[x].occNum == 0)
x++;
else
i++;
x++;
}
if (i == 0)
cout << "There are no smoking rooms available." << endl;
else if (i == 1)
cout << "There is " << i << " smoking room available." << endl;
else
cout << "There are " << i << " smoking rooms available." << endl;
//Sets x to 21 and checks all non-smoking rooms the same way.
x = 21;
while (x <= 100)
{
if (ho.room[x].occNum != 0)
x++;
else
j++;
x++;
}
if (j == 0)
cout << "There are no smoking rooms available." << endl;
else if (j == 1)
cout << "There is " << i << " smoking room available." << endl;
else
cout << "There are " << i << " smoking rooms available." << endl;
return;
}
void checkOut(Room r)
{
r.customer.printReceipt(r.bill, r.customer.CCNum);
r.clearRoom();
return;
}