vendredi 20 février 2015

How do I transverse a 2D array given an int top, bottom, left, and right?



new programmer here and I'm sort of having difficulty getting the gist of 2D arrays; and I'm completely stumped at what I'm supposed to do at the moment. But really what it is is that I'm given a public class called FloorPlan and that there's a private int[][] room, a simple 2D Array with filled with zeroes. I'm supposed to make a method called



private boolean isEmptyRegion(int top, int bottom, int left, int right)



where it returns true if the rectangular region between the top & bottom and between the left & right including the borders are only zeroes; and will return false otherwise. I'm given that top <= bottom and left <= right, as well as the region overall will be within the limits of room. Can anybody help me construct the for-loop to go through the borders of the 2D array and the dimensions I am given? Thank you.




Aucun commentaire:

Enregistrer un commentaire