Steffon Scott

Steffon Scott

  • NA
  • 20
  • 12.4k

Passing enumeration, invalid argument?

Apr 5 2013 1:48 AM
I have a constructor which is taking a enumeration argument to determine the properties of the instantiated object:

  public Support(playerClass playerClass)
        {
            if (playerClass == playerClass.Fighter) 
            {
                name = "Soldier";
                ambush = 0;
                attack = 4;
                copper = 0;
                defend = 4;
                range = 0;
                food = 1;
                mode = 0;
                numattacks = 1;
                regen = 0;
                shield = 0;
                swarm = 1;
                train = 0;
                firstStrike = false;
                type = 2;            
            }
        }



Now when I call this constructor and pass the argument I am getting an invalid argument error from VS. 


                case "soldier":
                    while (count >= 1)
                    {
                        units.Add(new Support(playerClass));
                        count--;
                    }
                    break;



Any ideas? From my understanding I AM passing the enumeration argument it should be expecting? Any help would be appreciated, thanks.

Edit: Also, here is the signature of the addUnit method:
public void addUnit(int amount, string type, playerClass playerClass)

Answers (3)