Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new method at the bottom of Picture.java. The declaration will be as fo

ID: 3624443 • Letter: C

Question

Create a new method at the bottom of Picture.java. The declaration will be as follows:

public Picture makeGrid(int size)
{
...
}

This method will create a square grid, size images wide by size images high, of duplicate copies of the original image. To be clear, the actual pixel dimensions of the grid may not be square, they will be proportional to the dimensions of the original image. Rather the number of images in the grid will be square. See the examples below for clarification.
At the beginning of the method you will create a new Picture object for the grid with the correct dimensions. At the end, you should return the new Picture object.

To test your method, use the following code as an example:
String fileName = ".../intro-prog-java/mediasources/caterpillar.jpg";
Picture original = new Picture(fileName);
Picture grid = original.makeGrid(3);
grid.show();

It should work with any image.

Explanation / Answer

public class Picture extends SimplePicture { //no arguments Constructor public Picture () { super(); } // Constructor that takes a file name and creates the picture public Picture(String fileName) { super(fileName); } public Picture(int width, int height) { super(width,height); } public Picture(Picture copyPicture) { super(copyPicture); } public Picture(BufferedImage image) { } public String toString() { String output = "Picture, filename " + getFileName() + " height " + getHeight() + " width " + getWidth(); return output; } public void minRed() { S1.jpg"; int loopvar = 0; Pixel[] pix = this.getPixels(); Pixel pickle = null; for(loopvar = 0; loopvar
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote