I'm currently working on a java project for a class in uni. One of the methods I must complete asks me to fill an Array with random numbers, but the array type is from a class called Weapon. I can't convert my type to integers so the compiler says that Weapons cannot be converted to integers.
I've tried searching for a solution, even writing a method called nextWeapon(), but as I just started learning programming, it seems to be a bit diffuclt.
int W;
Weapon[] weapons = new Weapon[W];
public Weapon[] createRandomWeapon(){
Random rand = new Random();
for(int i = 0; i < weapons.length; i++){
weapons[i] = rand.nextInt();
}
return weapons;
}
Aucun commentaire:
Enregistrer un commentaire