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, 21.06.2019 22:00
Formula that contains a nested function that first calculates the average of the values in range e6: p6 and uses the round function to round that average to the nearest 10 dollars. use -1 for the value of the number digit argument. would the formula be =round(average(e6: p6),0
Answers: 1
question
Computers and Technology, 22.06.2019 01:30
Imagine that you have a friend who is starting a small business and is interested in using social media to spread the word. he is not certain that it is a good move, and has come to you for . would you advise him to use social media to advertise his business? why or why not? support you answer with information from the text.
Answers: 1
question
Computers and Technology, 22.06.2019 04:00
Which of the following kinds of programs displays an online advertisement in a banner or pop-up window on webpages, email, or other internet service? e
Answers: 2
question
Computers and Technology, 22.06.2019 12:40
How do i get the most points, without any effort?
Answers: 2
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, 15.04.2020 22:23