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
Veseljchak [2.6K]
1 year ago
14

A Color class has three public, integer-returning accessor methods: getRed, getGreen, and getBlue, and three protected, void-ret

urning mutator methods: setRed, setGreen, setBlue, each of which accepts an integer parameter and assigns it to the corresponding color component. The class, AlphaChannelColor-- a subclass of Color-- has an integer instance variable, alpha, containing the alpha channel value, representing the degree of transparency of the color. AlphaChannelColor also has a method named dissolve (void-returning, and no parameters), that causes the color to fade a bit. It does this by incrementing (by 1) all three color components (using the above accessor and mutator methods) as well as the alpha component value. Write the dissolve method.
Computers and Technology
1 answer:
jek_recluse [69]1 year ago
6 0

Answer:

The following code are:

public void dissolve() {

setRed(getRed()+1);

setGreen(getGreen()+1);

setBlue(getBlue()+1);

alpha+=1;

}

Explanation:

Here, we define the void type function "dissolve()" inside it, we set three function i.e, "setRed()", "setGreen()", "setBlue()" and then we increment the variable "alpha" by 1.

Inside those three mutators method we set three accessor methods i.e, "getRed()", "getGreen()" , "getBlue()" and increment these accessor by 1.

The values will not be returned by the mutator functions, the accessor will be returned the values.

You might be interested in
The major result of treating 1-butyne with 6M aqueous NaOH would be:_______.A. the production of an alkene.B. the production of
andriy [413]

Answer:

D. nothing, as the alkyne would not react to an appreciable extent.

Explanation:

Nothing, as the alkyne would not react to an appreciable extent.

6 0
1 year ago
A file named data.txt contains an unknown number of lines, each consisting of a single integer. Write some code that creates two
Damm [24]

Answer:

I am doing it with python.

Explanation:

nums = '9 -8 -7 -6 -5 -4 -2 0 1 5 9 6 7 4'

myfile = open('data.txt', 'w')

myfile.write(nums)

myfile.close()

myfile = open('data.txt', 'r')

num1 = (myfile.read())

num1 = num1.split()

print(num1)

print(type(num1))

for x in num1:

   x = int(x)

   if x < 0:

       minus = open('dataminus.txt', 'a')

       minus.write(str(x) + ' ')

       minus.close()

   elif x>= 0:

       plus = open('dataplus.txt', 'a')

       plus.write(str(x)+' ')

       plus.close()

3 0
1 year ago
Read 2 more answers
Remember that ""state space"" refers to the space of all potential possibilities. Which dichotomous questions below will success
egoroff_w [7]

Answer:

Please check options are not given. Please check explanation for corrected version.

Explanation:

Options are not mentioned. Please post the complete question.

However, if "below" is removed, the question makes sense. I am taking it that way.

Dichotomous question means those questions which has two outcomes: true or false.

For the given condition, this is possible only if:

  • coin shows head and dice shows 1
  • coin shows head and dice shows 2
  • head, 3
  • head, 4
  • head, 5
  • head, 6
  • tails, and all above cases

However, each time, each mentioned condition should be strictly followed.

And fewer outcome than 1 is virtually or realistically impossible, as both coin and dice will roll out one outcome in any condition certainly.

7 0
2 years ago
Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for th
marishachu [46]

Answer:

Input code:

car_makers = {'Honda': 'Japan', 'Fiat': 'Germany'}

#add Tesla and USA as corresponding value

car_makers['Tesla'] = 'USA'

#change Fiat entry to Italy instead of Germany

car_makers['Fiat'] = 'Italy'

print(car_makers)

print('Honda made in', car_makers['Honda'])

print('Fiat made in', car_makers['Fiat'])

print('Tesla made in', car_makers['Tesla'])

Explanation:

The first line is a define object in the python code, containing two entries of Honda and Fiat and their respective countries.

The python code adds an entry to the object "car maker" using the bracket notation, the tesla car from USA.

The country of the Fiat car is changed from Germany to Italy, using the bracket notation.

The output of the complete object and the individual cars is given.

<u>output of the python code:</u>

{'Honda': 'Japan', 'Fiat': 'Italy', 'Tesla': 'USA'}

Honda made in Japan

Fiat made in Italy

Tesla made in USA.

7 0
1 year ago
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
1 year ago
Other questions:
  • Which of the following is not a benefit of active listening?
    8·1 answer
  • With respect to the general classes of computers, a ________ is the most expensive and most powerful kind of computer, which is
    7·1 answer
  • The attack in which the attacker sends a forged packet with the same source IP address and destination IP address in which the v
    10·1 answer
  • Write a program trapezoid.cpp that prints an upside-down trapezoid of given width and height. However, if the input height is im
    14·1 answer
  • Create a generic class Box with a type parameter that simulates drawing an item at random out of a box. This class could be used
    7·1 answer
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • 1. The precious metals needed to make computer chips, graphic cards, and transistors are found in only a small population of cou
    8·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Which of these are characteristics of a Python data type? Check all that apply.
    11·1 answer
  • All organizations need good quality cybersecurity to ensure _____. Select 4 options.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!