subject

Write a class square that represents a square to be drawn. store the following information in instance variables: size (length of any side) x coord of upper left-hand corner y coord of upper left-hand corner color provide the following methods:
a parameterless constructor that generates random values for the size, color, x, and y.
make the size between 100 and 200, x between 0 and 600, y between 0 and 400. the squares can be any color—note that you can pass a single int parameter to the color constructor, but it will only consider the first 24 bits (8 bits for each of r, g, b component).

important: your random number generator must be declared at the class level (not inside the constructor), and must be declared static. so its declaration and initialization should appear with the declarations of size, color, x, and y, and should look like this: private static random generator = new random();

a draw method that draws the square at its x, y coordinate in its color.

note that you need a graphics object, like the page parameter of the paint method, to draw.

your draw method should take a graphics object as a parameter.

now write an applet drawsquares that uses your square class to create and draw 5 squares. this code should be very simple; the paint method will simply create a square and then draw it, repeated 5 times.

don’t forget to pass the graphics object to draw.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 14:30
When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being displayed?
Answers: 1
question
Computers and Technology, 24.06.2019 19:20
Kiesha has a worksheet with a range of cells using the following columns: name, score, group, study group, and date. kiesha needs to sort the worksheet on the date field. which option she use to most efficiently complete this task ? a use the cut and paste option to reorganize the data to fit that order b use the filter function to organize the data based on the date c use the order function to organize the data based on the date d use the sort function to organize the data based on date order
Answers: 3
question
Computers and Technology, 25.06.2019 09:00
What do students buy when they pay tuition? o a place to live at a school o the right to attend classes at a school o transportation expenses to attend classes o textbooks
Answers: 2
question
Computers and Technology, 25.06.2019 15:30
Which of the following sets of acronyms is concerned with encoding data for secure transmission? wan, lan vpn, nic ipsec, ssh nat, ssl
Answers: 1
You know the right answer?
Write a class square that represents a square to be drawn. store the following information in instan...
Questions
question
Mathematics, 14.11.2020 01:10
question
Computers and Technology, 14.11.2020 01:10
question
English, 14.11.2020 01:10
Questions on the website: 13722363