In: Computer Science
Using C++ write a code that mimics a 911 call center where emergency calls are taken and routed to the appropriate emergency department. The code will need a class (or classes) that will hold information regarding an emergency. Calls are taken and the operator will use your program to assign values to your class objects to facilitate proper actions. Information recorded includes the address of the emergency, the name of the first responding fireman, officer, or other emergency personnel, an level of urgency, and other values related to such an application.
Write a description of what your class(es) could look like to get this information. Feel free to include actual class code, diagrams, or other tools to enhance your ideas.
Here i had provided the code with the sample output. think you understand about it. if not please comment i will assist you. please give me a like. it helps me a lot.
#include<iostream>
#include<vector>
#include<string>
using namespace std;
class Nine11Call
{
public:
string address; //the street address of the emergency
string respondent; //the name of the first responding officer or
emergency personnel
int urgencyLevel; //The higher the level, the more urgent, assume
always 0 - 20
bool needAmbulance;
/*
Note that an address must always be provided.
For constructors that exclude other attributes, use the fllowing
values, UNLESS OTHERWISE stated.
respondent= "John Blue"
urgencyLevel = 5
needAmbulance = false
*/
Nine11Call(string addr); //Only address is provided, use
defaults for other attributes
Nine11Call(string addr, bool ambulance); //Address and
needAmbulance is provided, use defaults for other attributes
EXCEPT
// if ambulance is needed, urgency is set to 15. So if no ambulance
needed, urgencyLevel = 5, otherwise 17
Nine11Call(string addr, int howUrgent, bool ambulance); //use the
default value for respondent
Nine11Call(string addr, string respondent, int howUrgent );
//needAmbulance set to false
Nine11Call(string addr, string respondent, int howUrgent, bool
ambulance ); // All attributes are provided
}
;
//Implement the constructor(s) and methods here
Nine11Call::Nine11Call(string addr) //Only address is provided, use
defaults for other attributes
{
address=addr;
respondent= "John Blue";
urgencyLevel = 5;
needAmbulance = false;
}
Nine11Call::Nine11Call(string addr, bool ambulance) //Address and
needAmbulance is provided, use defaults for other attributes
EXCEPT
{
address=addr;
respondent= "John Blue";
urgencyLevel = 5;
needAmbulance = ambulance;
}
// if ambulance is needed, urgency is set to 15. So if no
ambulance needed, urgencyLevel = 5, otherwise 17
Nine11Call::Nine11Call(string addr, int howUrgent, bool ambulance)
//use the default value for respondent
{
address=addr;
respondent= "John Blue";
urgencyLevel = howUrgent;
needAmbulance = ambulance;
}
Nine11Call::Nine11Call(string addr, string respondent, int
howUrgent ) //needAmbulance set to false
{
address=addr;
respondent= respondent;
urgencyLevel = howUrgent;
needAmbulance = false;
}
Nine11Call::Nine11Call(string addr, string respondent, int
howUrgent, bool ambulance ) // All attributes are provided
{
address=addr;
respondent= respondent;
urgencyLevel = howUrgent;
needAmbulance = ambulance;
}
//Implement the notify911() function here
void notify911(const Nine11Call &call){
if(0<=call.urgencyLevel &&
call.urgencyLevel<-10){
cout<<call.respondent<<" is responding to
"<<call.address<<". An ambulance ";
if(call.needAmbulance)cout<<"
is needed.";
else cout<<" is not
needed.\n";
}else if(11<=call.urgencyLevel &&
call.urgencyLevel<=15){
cout<<call.respondent<<" is responding to
"<<call.address<<" on a urgent call. An ambulance
";
if(call.needAmbulance)cout<<"
is needed.";
else cout<<" is not
needed.\n";
}else{
cout<<"Extremely urgent!
Emergency at "<<call.address<<". Notify the
Mayor!"<<endl;
}
}
int main()
{
//The following instantiations MUST work and assign the
attributes properly.
//If they do not, you've done something wrong.
Nine11Call cat("123 Maple Grove", "C. Simon", 0, false
);
Nine11Call whiteCollar("8 Wall Street" );
//Do not change this array
Nine11Call calls[6]={ Nine11Call("200 Campus Way", "Ofc. Mary
Kelly", 4),
Nine11Call("1782 20th Street", 19, true),
Nine11Call("302 29th Ave", 15, false),
Nine11Call("4 Box Way", 2, true),
Nine11Call("822 Jackson Street", true),
Nine11Call("1602 PA Ave") };
//Iterate the calls array and call notify911() for each
instance
for (int i=0 ;i<6;i++){
notify911(calls[i]);
}
return 0;
}
====================================================================