| 1 | package Question11_6; |
| 2 | |
| 3 | public class Coordinate implements Cloneable { |
| 4 | public int row; |
| 5 | public int column; |
| 6 | public Coordinate(int r, int c) { |
| 7 | row = r; |
| 8 | column = c; |
| 9 | } |
| 10 | |
| 11 | public boolean inbounds(int[][] matrix) { |
| 12 | return row >= 0 && |
| 13 | column >= 0 && |
| 14 | row < matrix.length && |
| 15 | column < matrix[0].length; |
| 16 | } |
| 17 | |
| 18 | public boolean isBefore(Coordinate p) { |
| 19 | return row <= p.row && column <= p.column; |
| 20 | } |
| 21 | |
| 22 | public Object clone() { |
| 23 | return new Coordinate(row, column); |
| 24 | } |
| 25 | |
| 26 | public void moveDownRight() { |
| 27 | row++; |
| 28 | column++; |
| 29 | } |
| 30 | |
| 31 | public void setToAverage(Coordinate min, Coordinate max) { |
| 32 | row = (min.row + max.row) / 2; |
| 33 | column = (min.column + max.column) / 2; |
| 34 | } |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected