You will write code that mimics a 911 call center where emergency calls are taken and routed to the appropriate emergency department. The class to hold information regarding an emergency is called Nine11Call. Information held in this class includes the address of the emergency, the name of the first responding fireman, officer, or other emergency personnel, an int of 0 - 20 representing the level of urgency, and whether or not an ambulance is needed.
Note that all class members are public, so there's no need for setter and getters.
Requirements:
Implement a function called notify911() that will accept a Nine11Call (by reference parameter), and output according to the following chart:
If the urgency is 0 - 10 output: _personnel_ is responding to _address_. An ambulance _is/is not_ needed. 11 - 15 output: _personnel_ is responding to _address_ on an urgent call. An ambulance _is/is not_ needed. otherwise output: Extremely urgent! Emergency at _address_. Notify the Mayor! Where, _personnel_ is the respondent name, _address_ is the address of the emergency _is/is not_ indicates whether or not an ambulance is needed Make sure the output ends with a newline.
_______________________________________________________________________________________________________
#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
//Implement the notify911() function here
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
return 0;
}
Thanks for the question.
Below is the code you will be needing Let me know if you have
any doubts or if you need anything to change.
Thank You !!
===========================================================================
#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;
}
====================================================================
Get Answers For Free
Most questions answered within 1 hours.