Friday, August 24, 2018

c# - Using C #, how can I set a variable to a random number within a range?

I've created a class called Superhero and given it the properties of:
string Name, int Life, int Punch, int Kick, and int Hyper Punch.



Then inside of my program in the main I created a List.



static void Main(string[] args)
{
List listOfHeroes = new List;
Superhero goodGuy = new Superhero();

goodGuy.Name = "Super Man";
goodGuy.Life = 100;
goodGuy.Punch =????
}


I want to be able to put in a range of numbers where the "????" are. My theory is that a user would be able to choose a hero from the list and be able to use him for battle. When he chooses the hero to throw a punch (or a kick or whatever) then a random number within a set range is assigned to that property.



So if it was a two player turn based game the property punch, when used, would take away from the other person's life property by the value of Punch. Is this a possibility or am I going about this incorrectly?




pseudo-random is ok.



Btw, I'm in 4th week of boot camp...so yell at me harshly if none of this makes sense so I can learn quicker lol.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...