Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions