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.

Answers: 3

Another question on Computers and Technology

Computers and Technology, 25.01.2019 18:30
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
Computers and Technology, 23.01.2019 20:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
Computers and Technology, 22.01.2019 17:11
Which of the following is an example of synchronous communication? a) e-mail b) voicemail c) telephone conversation d) text message.
Answers: 1
Computers and Technology, 17.01.2019 21:59
All nate specialties are offered at two levels, a. journeyman and master. b. installation and service. c. apprentice and journeyman. d. heating and air conditioning.
Answers: 1
You know the right answer?
Write a class square that represents a square to be drawn. store the following information in instan...
Social Studies, 13.07.2016 09:27
English, 21.05.2019 00:56
Mathematics, 07.03.2016 19:15
Questions on the website: 6654928