mardi 23 octobre 2018

How can I create a loop to randomly assign values to each characteristic of an array of class instances

So I am creating a card game that requires different cards, so I created a card class in which I declared the string value names and other interger values that are the powers eg.Intelligence So I created an array of instances of these classes Their names are read from a text file and assigned to the name value The part I am having trouble with is the part where I need to create a loop to randomly assign values to each power of each instance of a class. Here's what I've done so far

But when I print out the values all the instances have the same value for their powers. Eg Card 12 Intelligence = 6 And Card 14 Intelligence = 6 Can anyone please help me with this issue, and any guidance will be highly appreciated Thank you




Aucun commentaire:

Enregistrer un commentaire