When i compile it with the switch statments like this
it still doesn't work it compiles but when it shows up it says
4 burglar alarms installed in the computer room
this is correct and then it says
2 burglar alarms installed in the kitchen
this is wrong its supposed o be fire alarms but why???
well here is my whole source code:
main:
Code:
#include <iostream>
#include <stdlib.h>
#include "alarm.h"
void make(int amount, TYPE type, ROOM room);
int main(int argc, char *argv[])
{
Alarm comp(4, BURGLAR, COMPUTER);
make(comp.getAmount(), comp.getType(), comp.getRoom());
Alarm kit(2, FIRE, KITCHEN);
make(kit.getAmount(), kit.getType(), kit.getRoom());
system("PAUSE");
return 0;
}
void make(int amount, TYPE type, ROOM room)
{
cout<<amount<<" ";
switch(type)
{
case FIRE:
cout<<"fire";
break;
case BURGLAR:
cout<<"burglar";
break;
case WINDOW:
cout<<"window";
break;
}
cout<<" alarms where installed in the ";
switch(room)
{
case KITCHEN:
cout<<"kitchen.";
break;
case LIVING:
cout<<"living room.";
break;
case BED1:
case BED2:
case BED3:
cout<<"bed room.";
break;
case COMPUTER:
cout<<"computer room.";
break;
case BATH1:
case BATH2:
cout<<"bathroom.";
break;
}
cout<<"\n";
}
alarm.h:
Code:
#ifndef ALARM_H
#define ALARM_H
#include <iostream.h>
enum TYPE {FIRE, BURGLAR, WINDOW};
enum ROOM {KITCHEN, LIVING, BED1, BED2, BED3, COMPUTER, BATH1, BATH2};
class Alarm
{
public:
Alarm();
Alarm(int amount, TYPE type, ROOM room);
~Alarm();
ROOM getRoom() {return theRoom;}
int getAmount() {return theAm;}
TYPE getType() {return itsType;}
private:
int theAm;
TYPE itsType;
ROOM theRoom;
};
Alarm::Alarm()
{
}
Alarm::Alarm(int amount, TYPE type, ROOM room)
{
theAm = amount;
itsType = BURGLAR;
theRoom = room;
}
Alarm::~Alarm()
{
}
#endif
burglar