Question #37107

How would you code for a one-argument method Change_Status() that changes the occupancy status of the room to the value of its argument. The method should verify that the argument value does not exceed the room capacity. If it does, the method should return -1.
1

Expert's answer

2013-11-22T12:34:09-0500
#include <iostream>
#include <conio.h>
using namespace std;
class Room
{
public:
    void Set_Capacity(int newCapacity)
    {
        roomCapacity = newCapacity;
    }
    int Change_Status(int newValue)
    {
        if (newValue < roomCapacity)
    {
        roomStatus = newValue;
        return roomStatus;
    }
    else
        return -1;
    }
private:
    int roomCapacity;
    int roomStatus;
};
int main()
{
    Room room;
    room.Set_Capacity(40);
    int newStatus;
    cout << "Enter the new status for the room: ";
    cin >> newStatus;
    room.Change_Status(newStatus);
    cout << "There is "<< room.Change_Status(newStatus);
    _getch();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS