Looking through the code a million times i recognized when im running the code its works almost fine the Raktar class Randomallapot method makes a random status of a warehouse and after the BetarEgy class betar1 method storing into this warehouse, however when the programm goin further to the Fifo class then the Raktar class Randomallapot method runs again generating a new random status of the warehouse and the array what should contain the information of the stored items by betar1 method filled full of zero by default. So pls can u help me find why is it running 2 times instead of one and why the second times is it gets default zero elements int the "tomb" array(contains the range collumn information stored by betar1 method) when go further to the Fifo class.
im posting the the code again because i made some small fix in it but it isnt affect the the array problem. I put the classes in sequence by extends.
import java.util.Random;
public class Raktar {
public final Object raktar[][][] = new Integer[4][25][3];
Random gen = new Random();
int tav;
int mely;
int mag;
int textfield;
public static int seb= 5;
public void Randomallapot(){
int alapszam= gen.nextInt(60)+41;
int szamlal=20;
int tomb[][][] = new int[4][25][2];
int max=alapszam-szamlal;
System.out.println("Maxszam: "+max);
int sorszamlal=0;
int oszlopszamlal=0;
for (int k=0;k<(max+10);k++){
int sor=gen.nextInt(4);
int oszlop=gen.nextInt(25);
boolean volt=false;
for (int i=0; i<4; i++){
for (int j=0; j<25; j++){
if(i==sor && j==oszlop){
if(tomb[i][j][0]!=sor || tomb[i][j][1]!=oszlop && volt==false){
sorszamlal=i;
oszlopszamlal=j;
tomb[sorszamlal][oszlopszamlal][0]=sor;
tomb[sorszamlal][oszlopszamlal][1]=oszlop;
}
else if(tomb[i][j][0]==sor && tomb[i][j][1]==oszlop){
volt=true;
break;
}
}
}
}
for (int i=0; i<4; i++){
for (int j=0; j<25; j++){
if(i==tomb[sorszamlal][oszlopszamlal][0] && j==tomb[sorszamlal][oszlopszamlal][1]){
raktar[i][j][0]=1 + gen.nextInt(25)+(i*4);
raktar[i][j][1]=gen.nextInt(2);
raktar[i][j][2]=gen.nextInt(8)+1;
}else if(raktar[i][j][0]==null && raktar[i][j][1]==null && raktar[i][j][2]==null){
raktar[i][j][0]=0;
raktar[i][j][1]=0;
raktar[i][j][2]=0;
}
}
}
}
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
if (raktar[i][j][0]==null && raktar[i][j][1]==null && raktar[i][j][2]==null ){
raktar[i][j][0]=0;
raktar[i][j][1]=0;
raktar[i][j][2]=0;
}
}
}
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
System.out.print("["+raktar[i][j][0]+" "+raktar[i][j][1]+" "+raktar[i][j][2]+"] ");
}
System.out.println();
}
}
}
public class BetarEgy extends Raktar{
BetarEgy(){
super.Randomallapot();
}
int szam;
public final int tomb[][][]=new int[4][25][2];
public Object[][][] betar1(int textfield){
this.szam=textfield;
int szamlalo=0;
System.out.println("Textfield: "+textfield);
System.out.println("Betar raktar: ");
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
if (szamlalo<textfield){
if(raktar[i][j][0]==0 && raktar[i][j][1]==0 && raktar[i][j][2]==0){
raktar[i][j][0]=1 + gen.nextInt(25)+(i*4);
raktar[i][j][1]=gen.nextInt(2);
raktar[i][j][2]=gen.nextInt(8)+1;
tomb[i][j][0]=i;
tomb[i][j][1]=j;
System.out.print("["+raktar[i][j][0]+" "+raktar[i][j][1]+" "+raktar[i][j][2]+"] ");
szamlalo++;
}
}else{
break;
}
}
if(szamlalo==textfield){
break;
}else{
continue;
}
}
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
System.out.println("\n Range: "+tomb[i][j][0]+" Collumn: "+tomb[i][j][1]);
}
}
System.out.println("Final stored array: ");
for (int i=0;i<4;i++){
for(int j=0;j<25;j++){
System.out.print("["+raktar[i][j][0]+" "+raktar[i][j][1]+" "+raktar[i][j][2]+"] ");
}
System.out.println();
}
return raktar;
}
public int getTextfield(){
return textfield;
}
}
This is where the problem starts because i can't get any data of the BetarEgy class everything gets default here
public class Fifo extends BetarEgy{
boolean kitarolt=false;
double ido[]= new double[100];
double szamol;
public double[] FifoKitar1(){
for(int k=0; k<50;k++){
for(int i=0;i<3;i++){
for (int j=0;j<24;j++){
if(tomb[i][j][0]==i && tomb[i][j][1]==j){
System.out.println(" FifoRange: "+tomb[i][j][0]+" FifoCollumn: "+tomb[i][j][1]);
tav=((Integer)raktar[i][j][0]).intValue();
szamol=tav/(double)seb;
ido[k] = szamol;
raktar[i][j][0]=0;
raktar[i][j][1]=0;
raktar[i][j][2]=0;
kitarolt=true;
break;
}
}
if(kitarolt==true){
break;
}
}
}
return ido;
}
}
Thank in advance for any help