I have no idea how to do such thing, heres what I’ve tried:
public class Mage{
private int hp;
private int mp;
private String type;
private String weakness;
private int numSpell;//the input will tell you how long the array will be
public Mage(int ihp, int imp, String itype, String iweakness, int inumSpell, String[] ispells){
hp=ihp;
mp=imp;
type=itype;
weakness=iweakness;
private String[] spells = new String[inumSpell];
for(int i=0;i<ispells.length;i++){
spells[i]=ispells[i];
}
}
}
Would you consider my guess to be correct? Any help would be appreciated, thank you.
Though it looks a bit strange for what you are doing, coz you can simply do a ispells.length to get the no of spells instead of passing another int for such purpose. Anyway, here is what you should do base on your original code:
(a simplified version of your code)