I have a class called Player, in which I have three variables, one of which is a string array (playerInv) with ten values. How do I create a new Player in my main activity class using this Player class, with each index in the array having a null value ("")?
The Player Class:
public class Player {
private int playerPos;
private int playerHP;
private String playerInv[];
Player(int startPos, int startHP, String[] newInventory[]) {
playerPos = startPos;
playerHP = startHP;
playerInv = newInventory[10];
}
public int getPlayerPos() {
return playerPos;
}
public void setPlayerPos(int playerPos) {
this.playerPos = playerPos;
}
public int getPlayerHP() {
return playerHP;
}
public void setPlayerHP(int playerHP) {
this.playerHP = playerHP;
}
public String setPlayerInv(int pos) {
return playerInv[pos];
}
public void setPlayerInv(String inventory) {
for (int i = 0; i < 10; i++) {
this.playerInv[i] = playerInv[i];
}
}
}
Initializing the Player in the Main Activity
public void setupPlayer()
{
thePlayer = new Player(0,100,);
}
Thanks!