Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this in-class lab, we will create an array of objects and then iterate through each object, using the display() method to display each rectangle

For this in-class lab, we will create an array of objects and then iterate through each object, using the display() method to display each rectangle in a different location on the screen (and with different colors!)

Use the starter code below to get you going please fill out the commented areas with the necessary code in Java:

public class Rectangle {

private int x, y, w, h, r, g ,b;

public Rectangle(int x, int y, int w, int h, int r, int g, int b) {

this.x = x; this.y = y; this.w = w; this.h = h; this.r = r; this.g = g; this.b = b;

}

public void display() {

fill(r, g, b); rect(x, y, w, h);

}

}

void setup() {

size(600,600);

//create an array of Rectangle objects

//use a for loop to instantiate each spot as a Rectangle object

//randomize their positions and colors

}

void draw() {

//access the display() method for each Rectangle using a for loop

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago