Question
You are modifying some code for the department of Homeland Security. void terrorism (Action terrorist_action) { switch (terrorist_action) { case PLOT_ATTACK: if (alert_level == GREEN)
You are modifying some code for the department of Homeland Security.
void terrorism (Action terrorist_action)
{
switch (terrorist_action)
{
case PLOT_ATTACK:
if (alert_level == GREEN)
alert_level = ORANGE;
else if (alert_level == ORANGE) {
condemn_action();
alert_level = RED;
}
break;
case ALL_QUIET:
if (alert_level == RED)
alert_level = ORANGE;
else if (alert_level == ORANGE)
alert_level = GREEN;
else
go_golfing();
break;
default: break; // you may assume this never happens
}
}
Multi Part Question (enough detail must be given to fully justify your answer):
A) What principle does this violate? Justify your answer.
B) Why is this a Bad Thing? What are shortcoming of current design?
C) What would be the best pattern to use to to solve this issue? Explain and justify your choice.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started