hi every one...
i need some help from u..
i solved my assingment by my self an I need from u some help I will post my prgram and please check it if it need any edite or anything...


This is the mainClass

import java.util.*;
public class mainClass {
	
	public static void main(String []args){
		
		

		Scanner w = new Scanner(System.in);
		
		System.out.println("Please enter the size of the array: ");
		int size = w.nextInt();
		
		Cell arr [][]=new Cell [size][size];
		
		for (int a =0 ;a<size;a++){
			
		
			for (int e =0 ;e<size;e++){
				Cell f = new Cell();
				
				f.initializeColor();
				arr[a][e]=f;
				
		}
		}
		
		displayArray(arr, size);
		System.out.print("\n Enter the number ");
		int x=w.nextInt();
		
		System.out.print("\n Enter the second number ");
		int y=w.nextInt();
		
		
		int r= countCells(arr,x,y,size);
		System.out.print("\n Enter the second number "+r);
		
	
	   //please implement the main method
	
	}//end main
	
	
	/*
	 *The method countCells is a RECURSIVE method whose job is to find
	 *how many cells are in the same blob as a given cell (i.e cell with
	 *specified coordinates x and y). The variable int size represents the
	 *size of the two-dimensional array. This value would have been provided
	 *by the user at the beginning of the main method.
         *Do NOT make any changes to the method declartion.
	 */
	public static int countCells(Cell [][]cells,int x,int y,int size){
			
	Cell r=new Cell();
		
		if(x <0 || x>=size || y<0 || y >= size)
			return 0;
		else if (cells[x][y].getColor().equals(r.normal) || cells[x][y].getColor().equals(r.temp))
			return 0;
		else
		{
			cells[x][y].setColor(r.temp);
				return 1 
			
			+ countCells(cells, x - 1, y + 1, size ) + countCells(cells, x, y + 1, size )
			+ countCells(cells, x + 1, y + 1, size ) + countCells(cells, x - 1, y, size )
			+ countCells(cells, x + 1, y, size ) + countCells(cells, x - 1, y - 1, size )
			+ countCells(cells, x, y - 1, size ) + countCells(cells, x + 1, y - 1, size );
			
		}
	
	}//countCells()
	
	
	/*
	 * The method diplayArray is provided for you to call when you want to
	 * display your array on the screen. You should know how and when to 
	 * to use this method in your program by looking at its declaration and
	 * the expected output.Do NOT make any changes to this method.
	 */
	public static void displayArray(Cell [][]cells,int size){
		for(int i=0;i<size;i++){
			System.out.println();
			System.out.print("-");
			for(int j=0;j<size;j++){
				System.out.print("-+");
			}
			System.out.println();
			for (int j=0;j<size;j++){
				String color=cells[i][j].getColor();
				System.out.print("|"+color.charAt(0));
				
			}
			System.out.print("|");
			
		}//outer
		System.out.print("\n-");
		for(int j=0;j<size;j++){
			System.out.print("-+");
		}
	}//end displayArray()

}//end mainClass

This is th Cell

public class Cell implements Interface1{
	
	private String color;
	/*Please implement this class. Remember this class
	 * must implement all the methods declared in the interface
	 * Interface1.
	 */

	public String getColor() {
		// TODO Auto-generated method stub
		return color;
	}

	public void initializeColor() {
		// TODO Auto-generated method stub
		double a =Math.random()*10;
		if(a<7.0)
			color=normal;
		else
			color= abnormal;
		
	}

	public void setColor(String color) {
		// TODO Auto-generated method stub
		this.color=color;
	}


}

This is th interface ,

/**
 * Interface1 defines some constants and declares
 * some methods that must be implemented by the
 * class "Cell". The purpose of each method is
 * described below. Note the statement that says
 * public class Cell implements Interface1
 */
public interface Interface1 {
	final String normal="white";
	final String abnormal="green";
	final String temp="red";
	
	/**
	 * Method initializeColor will be used to initialize the color
	 * of each cell in the two-dimensional array.
	 * The cell can be one of two colors: "green" or "white". Whether 
	 * a cell will be "white" or "green" should be decided randomly.
	 * Since the assignment specifies that there should be more normal 
	 * (white) cells than abnormal (green) cells, you should devise an 
	 * algorithm that assigns:
	 * white: 70% of the time
	 * green: 30% of the time
	 * (hint:you can use Math.random() for this purpose)
	 */
	public void initializeColor();
	
	/**
	 * The method setColor is a typical setter method that
	 * sets the color of a given cell to a certain color.
	 * This method is needed especially to re-color a cell
	 * to a temporary color (i.e "red")
	 */
	public void setColor(String color);
	
	/**
	 * The method getColor will return the color of the 
	 * specified cell. This method is called to identify
	 * the color of the cell.
	 */
	public String getColor();

}

If you solved it then submit it. By asking as to check it you are requesting as to search for any errors you made by not reading your assignment properly to avoid any penalty and therefore you are openly cheating.
We do try to help with errors but we are not "babysitting" your programming attempts.

PS: Would be nice if you marked as solved previous posts and give credit at least this way to all these who helped you with it.

Briefly looking over it, it looks much better than your first post

if you have a specific problem with part of this let us know, but we can't test the entire program for you

in this code give me another solving it not work correctly

public void initializeColor() {
        // TODO Auto-generated method stub
        double a =Math.random()*10;
        if(a<7.0)
            color=normal;
        else
            color= abnormal;

    }

Edited 3 Years Ago by Nick Evan: Fixed formatting

here is a little easier

public void initializeColor() {		
if(Math.random() <= 0.7){
     color=normal;
}
else {
     color= abnormal;
}
}
This article has been dead for over six months. Start a new discussion instead.