import javafx.geometry.Point2D; public class PartImage { private boolean[][] pixels; private boolean[][] visited; private int rows; private int cols; public PartImage(int r, int c) { rows = r; cols = c; visited = new boolean[r][c]; pixels = new boolean[r][c]; } public PartImage(int rw, int cl, byte[][] data) { this(rw,cl); for (int r=0; r<10; r++) { for (int c=0; c<10; c++) { if (data[r][c] == 1) pixels[r][c] = true; else pixels[r][c]= false; } } } public int getRows() { return rows; } public int getCols() { return cols; } public boolean getPixel(int r, int c) { return pixels[r][c]; } // You will re-write the 5 methods below public void print() {} public Point2D findStart() { return null; } public int partSize() { return 0; } private void expandFrom(int r, int c) { } private int perimeterOf(int r, int c) { return 0; } public boolean isBroken(){ Point2D p = findStart(); expandFrom((int)p.getX(), (int)p.getY()); return (partSize() != 0); } public int perimeter() { Point2D p = findStart(); return perimeterOf((int)p.getX(), (int)p.getY()); } public static PartImage exampleA() { byte[][] pix = {{0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,0,0,0}, {0,1,1,1,1,1,1,0,0,0}, {0,1,1,1,1,1,1,1,1,0}, {0,0,0,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,0,0,0}, {0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,0,0,0}}; return new PartImage(10,10, pix); } public static PartImage exampleB() { byte[][] pix = {{1,0,1,0,1,0,1,0,0,0}, {1,0,1,0,1,0,1,1,1,1}, {1,0,1,0,1,0,1,0,0,0}, {1,0,1,0,1,0,1,1,1,1}, {1,0,1,0,1,0,1,0,0,0}, {1,0,1,0,1,0,1,1,1,1}, {1,1,1,1,1,1,1,0,0,0}, {0,1,0,1,0,0,1,1,1,1}, {0,1,0,1,0,0,1,0,0,0}, {0,1,0,1,0,0,1,0,0,0}}; return new PartImage(10,10, pix); } public static PartImage exampleC() { byte[][] pix = {{1,1,1,0,0,0,1,0,0,0}, {1,1,1,1,0,0,1,1,1,0}, {1,1,1,1,1,1,1,1,1,1}, {0,1,1,1,0,0,1,0,0,0}, {0,0,1,0,0,0,0,0,0,0}, {1,0,0,0,1,1,0,1,1,1}, {1,1,0,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1}, {0,0,1,1,0,1,1,1,1,1}, {0,0,1,0,0,0,1,1,0,0}}; return new PartImage(10,10, pix); } public static PartImage exampleD() { byte[][] pix = {{1,0,1,0,1,0,1,1,0,0}, {1,0,1,0,0,0,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1}, {1,0,1,1,1,1,1,1,1,0}, {1,0,0,1,0,0,1,0,0,0}, {1,1,0,0,0,1,1,0,0,1}, {0,1,0,0,0,0,0,0,1,1}, {0,1,0,1,0,0,0,0,0,0}, {0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0}}; return new PartImage(10,10, pix); } }