Beginner question about using class objects

I'm making a game and using objects to represent enemy monsters. I want to use a random selection to select which monster attacks at a certain stage.

I have a class.cs file and a program.cs file in my Visual Studios project.

In my class.cs file I have

public class Monster { // instance variables... public int monsterNum; public string monsterName; public int monsterStrength; //constructor... public Monster(int monsterNum, string monsterName; int monsterStrength) this.monsterNum = monsterNum; this.monsterName = monsterName; this.monsterStrength = monsterStrength; } // and in my Program.cs... Monster snake = new Monster(1, "Snake", 10); Monster centaur = new Monster(2, "Centaur", 15); Monster mummy = new Monster(3, "Mummy", 20); Monster dragon = new Monster(4, "Dragon", 40); while (true) { Random randMonster = new Random(); int appearingMonster = randMonster.Next(1, 5); 

/* my goal is to use my random number generator to represent the monsterNum of one of my monsters. And then I was thinking of using that random number to select the monster and have him attack (I use a method of his strength versus player strength etc etc.) Am I on the right track? Is there a way to do something kinda like the SQL equivalent of… */ Select monsterStrength from Monster where monsterNum = int appearingMonster // thanks guys!

by gavinrendar via /r/csharp

Leave a Reply