answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zzz [600]
2 years ago
12

The code selection above is taken from the Color Sleuth activity you just completed. This selection would count as an abstractio

n on the Create PT, but to earn Row 8 you will need to describe how this abstraction manages complexity. Write response 2d describing the abstraction above. Use the writing prompt and scoring guidelines as a guide.
Computers and Technology
1 answer:
Vinvika [58]2 years ago
4 0

Answer:

b

Explanation:

You might be interested in
Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
Alex787 [66]

Answer:

One of the strategies to avoid nested conditional is to use logical expressions such as the use of AND & operator.

One strategy is to use an  interface class with a method. That method can be created to be used for a common functionality or purpose. This is also called strategy design pattern. You can move the chunk of conditional statement to that method. Then each class can implement that interface class and use that shared method according to their own required task by creating objects of sub classes and call that common method for any such object. This is called polymorphism.

Explanation:

Nested conditionals refers to the use of if or else if statement inside another if or else if statement or you can simply say a condition inside another condition. For example:

if( condition1) {  

//executes when condition1 evaluates to true

  if(condition2) {

//executes when condition1  and condition2 evaluate to true

  }  else if(condition3) {

 //when condition1 is true and condition3 is true

} else {

 //condition1  is true but neither condition2 nor conditions3 are true

}  }

The deeply nested conditionals make the program difficult to understand or read if the nested conditionals are not indented properly. Also the debugging gets difficult when the program has a lot of nested conditionals.

So in order to avoid nested conditionals some strategies are used such as using a switch statement.

Here i will give an example of the strategies i have mentioned in the answer.

Using Logical Expressions:

A strategy to avoid nested conditionals is to use logical expressions with logical operators such as AND operator. The above described example of nested conditionals can be written as:

if(condition1 && condition2){  //this executes only when both condition1 and condition2 are true

} else if(condition1 && condition3) {

this executes only when both condition1 and condition3 are true

} else if(condition1 ){

//condition1  is true but neither condtion2 nor condtion3 are true  }

This can further be modified to one conditional as:

if(!condition3){

// when  condition1 and condition2 are true

}

else

// condition3 is true

Now lets take a simple example of deciding to go to school or not based on some conditions.

if (temperature< 40)

{

   if (busArrived=="yes")

   {

       if (!sick)

       {

           if (homework=="done")

           {

               printf("Go to school.");

           }

       }                    

   }

}

This uses nested conditionals. This can be changed to a single conditional using AND logical operator.

if ((temperature <40) && (busArrived=="yes") &&

(!sick) && (homework=="done"))

{    cout<<"Eligible for promotion."; }

The second strategy is to use an interface. For example you can

abstract class Shape{

//declare a method common to all sub classes

  abstract public int area();

// same method that varies by formula of area for different shapes

}

class Triangle extends Shape{

  public int area() {

     // version of area code for Triangle

return (width * height / 2);

  }

}

class Rectangle extends Shape{

  public int area() {

     // version of area code for Rectangle

    return (width * height)

  }

}

// Now simply create Rectangle or Triangle objects and call area() for any such object and the relevant version will be executed.

4 0
2 years ago
Recall that a Set is an abstract data type somewhat similar to a Bag, they can store a finite collection of objects without any
lina2011 [118]

Answer:

Here is the addLikeASet() method:

public boolean addLikeASet(T anEntry){  // method takes the T parameter anEntry

       boolean res = true;  //sets the result to true

       if(Arrays.asList(bag).contains(anEntry);  {  //checks if the bag already contains anEntry

           res=false;         }  //returns false

       else         {   if the bag does not already contain anEntry

           bag[numberOfEntries]=anEntry;  //enters the anEntry in bag array

           numberOfEntries++;         }  //increments the  numberOfEntries by 1

       return res;     } //returns true

Explanation:

You can also implement this method like this:

public boolean isFilled(){ // the function to check if the bag is full

       return numberOfEntries == bag.length;  } // number of entries equals length of the bag which shows that the bag is full

public boolean addLikeASet(T anEntry){

       boolean res=true;

       if (!isFilled() || (Arrays.asList(bag).contains(anEntry));  //checks if the bag is full or contains anEntry already

           res=false;         //returns false

       else         { if bag does not already contain anEntry

           bag[numberOfEntries]=anEntry; //add anEntry to the bag

           numberOfEntries++;         } add 1 to the count of numberOfEntries

       return res;     } //returns true

You can also use a loop to check if anEntry is already present in bag:

for(int i=0; i< bag.length; i++)  {

    if(anEntry.equals(bag[i])) {

      return false;      }    }  

  return true;

3 0
2 years ago
Theo is inspecting his document before he shares his PowerPoint. Which aspects can be inspected by the document inspector? Check
ryzh [129]

comments and annotations


document properties and personal information


invisible on-slide content


presentation notes


5 0
2 years ago
Read 2 more answers
You use the _____ sheet in the format cells dialog box to position data in a cell by centering it, for example.â
Murljashka [212]
The alignment sheet

The alignment sheet in the format cells dialog box is used to position data in a cell by left or right aligning, centering, aligning at the top or bottom and rotating as well. For instance, if you choose to enter 90 in the degree area, the text will read vertically from bottom to top in the cell.


3 0
2 years ago
Targeting encourages drivers to scan far ahead and _____________. A. focus their visual attention on the next point on the road
Colt1911 [192]
<span>A. focus their visual attention on the next point on the road.  A driver must have a target, it can be the car in front, a building pr a structure on the road.  Targeting enables the driver to look further ahead on the road and thus be ready for any obstacle on the road.</span>
3 0
2 years ago
Read 2 more answers
Other questions:
  • Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
    6·2 answers
  • What happens it the offshore team members are not able to participate in the iteration demo due to time zone/infrastructure issu
    11·1 answer
  • A company wants to publish Knowledge articles to its Customer Community. The articles should be organized for easy navigation by
    6·1 answer
  • The OSI security architecture provides a systematic framework for defining security attacks, mechanisms, and services. True or F
    12·1 answer
  • python Write a function that computes a future investment value at a given interest rate for a specified number of years. The fu
    11·1 answer
  • Write a method printShampooInstructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, prin
    14·1 answer
  • A program is divided into 3 blocks that are being compiled on 3 parallel computers. Each block takes an Exponential amount of ti
    6·1 answer
  • Write a python 3 function named words_in_both that takes two strings as parameters and returns a set of only those words that ap
    7·2 answers
  • TQ Artificial Intelligence (AI)
    15·1 answer
  • A major clothing retailer has requested help enhancing their online customer experience. How can Accenture apply Artificial Inte
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!