Question: Image Class Java 2. Image Class Name: Image.java An image is essentially a grid of pixels. Thus, we can use a 2D array of Pixel

Image Class Java

Image Class Java 2. Image Class Name: Image.java An image is essentially

a grid of pixels. Thus, we can use a 2D array of

2. Image Class Name: Image.java An image is essentially a grid of pixels. Thus, we can use a 2D array of Pixel objects to represent an image Create a Image class as specified in the UML diagram Image - width: int -height: int data: PixelID +Pixel0 + Pixel(width: int, height int, data: Pixel[]D +toString0): String +getWidth0: int +setWidth(width: int) +getHeight0: int +setHeight(width: int) +getData): PixelIU +setData(data: PixelD0) + setPixel(row: int, column: int, pixel: Pixel) toString0 is to return a string representation of the Image object specifying the dimensions and displaying the data like this: Dimensions: 5 by 5 Data: (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, O) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, O) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, O) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, O) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, O) The setters should validate that width and height are greater than zero. Add a main0 method to the Image class that creates an Image object. Add five random pixels at random locations in the image (i.e., use createRandomPixel0 to generate the random pixel and then choose a random row and random column to for each random pixel and then use toString0 method. Example Output: imagel: Dimensions: 5 by 5 Data: (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (179, 183, 240) (0, 0, 0) (O, 0, 0) (14, 186, 164) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) (252, 70, 127) (0,0, 0) (0, 0, 0) (123, 94, 55) (115, 206, 114)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!