My header is as follows
const int TURN_ON=1;
const int TURN_OFF=0;
class lightControl
{
private:
const int NUM_ROOMS;
const int NUM_FLOORS;
int building[10][10];
public:
lightControl(int,int,int);
int getStatus(int,int);
void turnOn(int,int);
void turnOff(int,int);
void printAll();
};
While my def is
#include "lightControl.h"
lightControl::lightControl(int x, int y, int TURN_OFF):NUM_FLOORS(x) NUM_ROOMS(y)
{
for(int i=0; i < NUM_FLOORS; i++)
for(int j=0; j < NUM_ROOMS; j++)
building[i][j]=TURN_OFF;
}
void lightControl::turnOn(int, int)
{
building[x][y]=TURN_ON;
}
void lightControl::turnOff(int,int)
{
building[x][y]=TURN_OFF;
}
int lightControl::getStatus(int,int)
{
return building[x][y];
}
void lightControl::printAll()
{
for(int i=0; i < NUM_FLOORS; i++)
for(int j=0; j < NUM_ROOMS; j++)
cout<<"Floor Number "<< i <<"Room Number "<< j << "light is (1 on / 0 off)" <<building[i][j] << "\n";
}
and my main function is
#include <iostream>
#include "lightControl.h"
;using namespace std;
int main(){
int x, y, room_Num, floor_Num, status;
char cont;
char onOff;
cout << "How many floors are there in the building(must be less than 10) " << "\n";
cin >> x;
cout << "How many rooms are there per floor (must be less than 10) " << "\n";
cin >> y;
lightControl lightControl(x,y,TURN_OFF);
cout << "Do you wish to turn any lights on/off (Y for yes N for no)" << "\n" ;
cin >> cont;
while (cont == 'y' || cont == 'y'){
cout << " DO you wish to turn lights on? (Y for yes N for no)" << "\n" ;
cin >> onOff ;
if (onOff == 'y' || onOff == 'Y'){
cout << " What room is it that you wish to turn on? " << "\n";
cin >> floor_Num;
cout << " What floor is this located on? " << "\n";
cin >> room_Num;
lightControl turnOn(floor_Num, room_Num);
else
cout << " What room is it that you wish to turn off? "<< "\n";
cin >> floor_Num;
cout << " What floor is this located on? " << "\n";
cin >> room_Num;
lightControl turnOn(floor_Num, room_Num);
status = lightControl getStatus (floor_Num, room_Num);
cout << "The rooms light is now" << status << "1 = on and 0 = off" << "\n";
}
cout << "Do you wish to continue turning lights on/off? " << "\n";
cin >> cont;
}
lightControl printAll();
return 0;
}
any suggestions on how to get it to run
its simply supposed to be a function were you can turn different lights on/off in the building"array"