Building battle ship in processing. How do i connect the ships together and randomize the location of the ships?

ive been working on this side project trying to make a battle ship game from some time now. I have come across a few things I do not know how to do. I was wondering if anyone knew how I could make each of the five ships with their appropriate lengths and then randomize their location on the boards.

I draw the two boards like this in my void setup()

 //drawing grid
for(int i = 0; i < 10; i++){
for(int j = 0; j <10; j++){
}
}


here is where I create the matrix for the ships and the hit icons. I do it in their own class in order to try and keep my main kinda clean

ObjGame(int xi, int yi){
ship = random(5)<.5;

x = xi;
y = yi;
}
void draw(){
pushMatrix();
translate(x,y);
fill(25,200,222);
stroke(c1,c2,c3);
rect(0,0,50,50);

if(!ship && clicked){
fill(255); //white circle for miss);
ellipse(25,25,30,30);
}
else if(ship && clicked){
fill(255,0,0); //red circle for hit
ellipse(25,25,30,30);
}
else{
fill(25,200,222);
rect(0,0,50,50);
}
popMatrix();
}

void attacked(){
if(mouseX <= 500){
if(mouseX> x && mouseX< x+ 50 && mouseY > y && mouseY < y+50){
clicked = true;
println(x+" "+y);
}
}


i am also trying to print out their coordinates but I want them to print out 0 - 9 instead of their actual x and y coordinates, is there an easy way to fix that or should I just be switching them?

• thank you for moving your question from stackoverflow.com/questions/59169235/… +1 – Martin Frank Dec 4 '19 at 8:20
• @Tim Holt thank you for pointing out the differences between java and processing - since the details on stackoverflow are more helpful than these on gamedev i know now what was wrong with my anser and i'll withdraw it. – Martin Frank Dec 10 '19 at 5:25