hello again every body ...


i tried 2solveit ,but there are some problem faced me .. and i'll insert what i did .>>>

This is the main class..the main problem in it how 2 print the array like the example which i show it 2 u ...

import java.awt.DisplayMode;
import java.util.Scanner;



public class mainClass {

private static String[][] Cell;
final static String normal="white";
final String abnormal="green";
final static String temp="red";


public static void main(String []args){

Scanner w = new Scanner(System.in);
Cell c1 = new Cell();
//please implement the main method

System.out.println("Please enter the size of the array: ");
int size = w.nextInt();

displayArray();

c1.initializeColor(size);

System.out.print("Please enter the the cordinates to chek: ");

System.out.println("r: ");
int x = w.nextInt();

System.out.println("c: ");
int y = w.nextInt();

countCells( x, y);



}//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( int x, int y){
int count=0;

for(int x1=0; x1<Cell.length; x1++)
for(int y1=0; y1<Cell.length; y1++){
Cell[x][y]=normal;
}

for(int x1=0; x1<Cell.length; x1++)
for(int y1=0; y1<Cell.length; y1++){
if(getblobsize(x,y, Cell) > 0)
count++;
}
System.out.print("The number of blobs: " + count);
return count;

}//countCells()




private static int getblobsize(int r, int c, String Cell[][]) {

if(r<0 || r>=Cell.length || c<0 || c>=Cell.length){
return 0;
}

if(Cell[r][c] == temp || Cell[r][c] == normal){
return 0;
}

else{
int time=1;

time += getblobsize( r - 1, c + 1, Cell);
time += getblobsize( r, c + 1, Cell);
time += getblobsize( r + 1, c + 1, Cell);
time += getblobsize(r + 1, c, Cell);
time += getblobsize( r + 1, c - 1, Cell);
time += getblobsize( r, c - 1, Cell);
time += getblobsize( r - 1, c - 1, Cell);
time += getblobsize( r - 1, c, Cell);
return time;

}
}




/*
* 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 [][] ,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 the Cell class >>>>

public class Cell implements Interface1{

private String color;
final String normal="white";
final String abnormal="green";
final String temp="red";
private int column;
private int row;

/*Please implement this class. Remember this class
* must implement all the methods declared in the interface
* Interface1.
*/

/**
* 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(int size) {
// TODO Auto-generated method stub
Cell[][] Cell = new Cell[row][column];
int d=(size*(70/100));
int b=(size*(30/100));
for (int size1 = 0; size1 < row; size1++){
while(row <= d);{
do([row] = setColor(normal);
}
}
for (int size1 = 0; size1 < column; size1++) {
while(column <= b);{
do([column] = setColor(abnormal);
}
}
}

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

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

public void initializeColor() {
// TODO Auto-generated method stub

}


}

And this is the 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();

}

i need help ..:(

Comments
Chat language, extensive use of red colour, didn't point exact errors and didn't close previous post. What to do with you?

You are having problems calling displayArray from your main method?

I see you are creating one cell, how are you creating the rest?

In the instructions it states:

As you can see from the above two runs, the user will be asked to specify the size of the twodimensional
array. So if the user inputs the value (5), then the array should be of the size [5][5].

The elements of the
array are instances of the class “Cell” which is included as one of the three files. This class must
have one data field only:
private String color;


Your cell implementation doesn't fit the instructions.

Take time and read before you start coding. This isn't the easiest problem in the world, nor hardest, but not one to go haphazardly into. Break it into steps. I see you are in Algorithms and Data Structures, and I'm sure they aren't teaching code first.

Comments
More patience than this poster has earned.

you already have to code to display the array

your comments for that method state
Do NOT make any changes to this method.

show me some effort that you can create an array on your own
if it doesn't work big deal, show us you have the effort for us to help

this is the file bellow .. download and explain what u understand my frind

This (your existence on this site) must be some kind of a sociology experiment. If so, I guess the goal would be to figure out how much help you can receive from people while disregarding what they say, being annoying, and ignoring all of the rules for human social interaction.


Ask a specific question: this involves identifying some specific concept you do not fully understand and explaining what you do and don't understand about it, as well as your reasons (if any) for not understanding.

Comments
couldn't have put it better myself

i need help ..:(

yeah you do.. not necesarilly ours though.
if I read over this code you've posted, it seems that in the comments you can write flawless (or almost flawless) english, while in your posts, you only reach to the level of my 2-year old cousin's english, and he has never even heard english, let alone tried to speak/write it.

this gives me the idea that you did not write this code, this was given to you as your assignment, or as aid by someone who did you one huge favour.

stop trying to cheat your way through, and put some effort in it yourself.

you already have to code to display the array

your comments for that method state
Do NOT make any changes to this method.

this shows you haven't even read your assignment, so, why should we?

Comments
You just nailed him...

upon my word I wrote this code and no one given to me as my assignment, or anything else >> please choose your word carefully>>
And I'm sorry to ask help from you>>

yeah you do.. not necesarilly ours though.
if I read over this code you've posted, it seems that in the comments you can write flawless (or almost flawless) english, while in your posts, you only reach to the level of my 2-year old cousin's english, and he has never even heard english, let alone tried to speak/write it.

this gives me the idea that you did not write this code, this was given to you as your assignment, or as aid by someone who did you one huge favour.

stop trying to cheat your way through, and put some effort in it yourself.

this shows you haven't even read your assignment, so, why should we?

upon my word I wrote this code and no one given to me as my assignment, or anything else >> please choose your word carefully>>
And I'm sorry to ask help from you>>

Listen to us, this post will end up like the last post, we made a little progress to start with, but as you noticed once you started telling us show me how to do it without any effort it all went down hill.

Take the advice and as we keep saying, read our posts, read your instructions, and show effort, then you can get your assignment back on track.

This article has been dead for over six months. Start a new discussion instead.