For starters, I have two classes that are relevant: Enemies.java and Sarz.java. Enemies extends Sarz.
public class Enemies extends Sarz {
It has an array with some enemy objects inside.
enemies[0] = new Enemies("Dragon", 100, 100, "Cave");
enemies[1] = new Enemies("Saturn Fly Trap", 10, 15, "Forest");
In Sarz, I make an array of type Sarz and in it I store some randomly generated enemies.
Enemies e = new Enemies();
e.generateEnemies();
Sarz[][] map = new Sarz[5][5];
while (count < 4){
row = r.nextInt(5);
column = r.nextInt(5);
if (map[row][column] == null){
map[row][column] = e.enemies[r.nextInt(8)];
System.out.println(map[row][column].getName() + " at " + row + "," + column);
count++;
}
}
My problem is that when I use that println statement to test, they have been stored correctly in random spots, but I cannot seem to get anything to return the enemy name to me. I have tried using Arrays.toString() and the getters and setters of the Enemies class, but they will not work on the map array because it is of type Sarz. I would like to be able to use map[row][column].getEnemyName() or at least something to return a String instead of Enemies@14ae5a5 at 1,0.