src/com/project/barrenland/processor/AreaCalculator.java
public List<Integer> calculateArea(final Farm farm) {
        int[][] nodes = farm.getFarmLand();
        List<Integer> areas = new ArrayList<Integer>();

        // Marker represents the type of land. Fertile lands start from market 2
        int marker = Constants.FERTILE_LAND_MARKER_START;

        for (int i = 0; i < nodes.length; i++) {
            for (int j = 0; j < nodes[0].length; j++) {
                // Traverse nodes not visited
                if (nodes[i][j] == Constants.UN_VISITED_MARKER) {
                    Queue<Coordinate> queue = new LinkedList<Coordinate>();
                    queue.add(new Coordinate(i, j));
                    int area = bfs(queue, nodes, marker++);
                    areas.add(area);
                }
            }
        }

        Collections.sort(areas);
        return areas;
    }
/**
     * calculates the fertile land area
     *
     * @param farm
     * @return
     */
calculates the fertile land area
@param farm
@return
calculates the fertile land area @param farm @return
public List<Integer> calculateArea(final Farm farm) {
        int[][] nodes = farm.getFarmLand();
        List<Integer> areas = new ArrayList<Integer>();
        int marker = Constants.FERTILE_LAND_MARKER_START;
        for (int i = 0; i < nodes.length; i++) {
            for (int j = 0; j < nodes[0].length; j++) {
                if (nodes[i][j] == Constants.UN_VISITED_MARKER) {
                    Queue<Coordinate> queue = new LinkedList<Coordinate>();
                    queue.add(new Coordinate(i, j));
                    int area = bfs(queue, nodes, marker++);
                    areas.add(area);
                }
            }
        }
        Collections.sort(areas);
        return areas;
    }
public List < Integer > calculateArea ( final Farm farm ) { int [ ] [ ] nodes = farm . getFarmLand ( ) ; List < Integer > areas = new ArrayList < Integer > ( ) ; int marker = Constants . FERTILE_LAND_MARKER_START ; for ( int i = 0 ; i < nodes . length ; i ++ ) { for ( int j = 0 ; j < nodes [ 0 ] . length ; j ++ ) { if ( nodes [ i ] [ j ] == Constants . UN_VISITED_MARKER ) { Queue < Coordinate > queue = new LinkedList < Coordinate > ( ) ; queue . add ( new Coordinate ( i , j ) ) ; int area = bfs ( queue , nodes , marker ++ ) ; areas . add ( area ) ; } } } Collections . sort ( areas ) ; return areas ; }
calculates the fertile land area
 @param farm
 @return
calculates the fertile land area @param farm @return
// Marker represents the type of land. Fertile lands start from market 2 // Traverse nodes not visited