subject
Computers and Technology, 11.05.2021 22:30 babas97

For this part of the programming checkpoint, you need to write a segmentation method within the Picture. java class that will create an inner square segment inside a picture. This method will be called segment (int xPos, int yPos, int sWidth), which takes three parameters which are the x(xPos) and y(yPos) coordinate of the upper left corner of an inner square in addition to the width (sWidth) of the inner square that will be segmented. The method should do the following:
Check if sWidth is positive.
Check that the given sWidth is less than or equal to half of the picture’s width. The same should be checked for the height
Check that the xPos and yPos are valid so the square will be drawn within the original picture height and width. i. e., (xPos +sWidth) should be less than the picture width, and (yPos +sWidth) should be less than the picture’s height.
Iterate through every pixel in the inner square and check the RGB components as follow:
Find out which color component of a pixel has the highest value
Make the highest value the dominant color component by resetting the other color components to zero.
This method will show the selected square portion partitioned into three colors based on the dominant color component. When you think you have it right, compile your code, and use the interactions pane to test your new method. Below are some tests:
> import java. awt.*;
> Picture pic = new Picture(FileChooser. pickAFile());
> pic. segment(40,50,-200);
Error: inner square width should not be negative -200
> pic. segment(40,50,260);
Error! inner square width must be less than half the width and height.
> pic. segment(480,50,200);
Error! inner square top left should be within the picture limits
> pic. segment(150,250,200);
> pic. show();

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
When determining the classification of data, which one of the following is the most important consideration? a. processing systemb. valuec. storage mediad. accessibility
Answers: 2
question
Computers and Technology, 22.06.2019 10:40
Program using c++ only on visual studio pig is a simple two player dice game, played with one die. the first player to reach or surpass 50 is the winner. each player takes a turn rolling the dice. they add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. the risk being they could lose the amount they’ve accumulated into the pot. the rules for each player’s die roll. 1. roll the dice. a. if user rolled a 1, i. the pot gets set to zero ii. the other player goes to step 1. b. a roll of 2-6 is added to the pot. 2. user can choose to hold or roll again. a. choice roll. return to step 1. b. choice hold. i. increment player score by the pot amount. ii. pot gets set to 0. iii. second player gets to roll and goes to step 1. program requirements: ● before each opponent begins ○ output the score for the person and the computer. ○ output the opponents whose turn is beginning and ask the user to hit enter to continue. ● with each dice roll. ○ output the die value, and amount of the round pot. ○ if it’s the users roll ask if they want to roll again ( r ) or hold ( h ). your program should allow r, r, h or h as valid input. if input is anything else, ask the user again until valid input is obtained. ○ the ai will continue playing until the round pot is 20 or more. ● once a player’s score is greater or equal to 50 then they have won, it will no longer ask if they want to keep rolling the die or not. ● once there is a winner ○ score totals are output along with who the winner was. user or computer ○ player is asked if they want to play again y or n. valid input should be y, y, or n, n. ● when a new game starts the starting roll goes to the player that did not roll last. if the user rolled last in the previous game, then the computer rolls first and vice versa. when the program first begins, the player will make the first roll of the first game. development notes : ● you will need a way to roll dice in your program. the rand() function works well, but returns an integer. if we want numbers 0 – 9 we can get the value modulus 10. ● call srand() with a value to seed it. it’s common to seed it with the current computer clock, include ctime, and then call srand(time(
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i.e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
question
Computers and Technology, 23.06.2019 04:20
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy.a. a fire occurs on the premises, and the building isbadly damaged.b. a burglar steals some money and securities from anunlocked safe.c. a business computer is damaged by vandals whobreak into the shop after business hours.d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm.til
Answers: 2
You know the right answer?
For this part of the programming checkpoint, you need to write a segmentation method within the Pict...
Questions
question
Spanish, 03.12.2020 17:30
question
Mathematics, 03.12.2020 17:30
Questions on the website: 13722367