I
iMohed
Hello guys. I wanted to wright something that filled a vector with
objects of the same type. Sins I don't know how many objects there is
going to be beforehand I wanted some way to generate names for them
when they are created. I tried something like the algorithm below but
it's not working. Any help or suggestions would be welcome and thanks
in advance.
public class Board {
public int numSquares;
Square[] sq = {};
public void mksquares(int k){
for (int i = 0; i < k; i++){
Square genName("Sq", i) = new Square(); // "here is
the rub"
}
public String genName(String s, int i){
String name = new String();
name.concat(s+i);
return name;
}
}
public class Square {
int p;
int value;
Color c;
}
}
Mohamed Haidar.
objects of the same type. Sins I don't know how many objects there is
going to be beforehand I wanted some way to generate names for them
when they are created. I tried something like the algorithm below but
it's not working. Any help or suggestions would be welcome and thanks
in advance.
public class Board {
public int numSquares;
Square[] sq = {};
public void mksquares(int k){
for (int i = 0; i < k; i++){
Square genName("Sq", i) = new Square(); // "here is
the rub"
}
public String genName(String s, int i){
String name = new String();
name.concat(s+i);
return name;
}
}
public class Square {
int p;
int value;
Color c;
}
}
Mohamed Haidar.