#instance failure
1 messages · Page 1 of 1 (latest)
Where do you set moneys, shopItems, and pay?
Do I have to assign them to the shop class? I thought it was enough to refer to the classes like moneys.money
Which Money do you want the variable moneys to hold
Ah I see, I got a bit confused there. money, is the field in the other script which holds the value, and moneys is the instance for the class, if that is what you mean?
A variable is like a shoebox full of data. The box can fit a Money in it, and is named moneys. Whenever you refer to moneys in the script, it pulls the shoebox off the shelf, grabs the Money out of it, and gives it to the code
Yeah so the code should go like this right?
moneys (instance) -> Money (Class) -> money (variable) ?
by doing this moneys.money
A class is just a pattern that tells the instance what sort of stuff it has
So, you create an instance of the Money class, then that class is no longer part of the picture. It's just the type that object is
moneys the instance has a money variable
Ah I think I know now, I have to make an instance for that variable too. So I make another int, and do this mon = moneys.money; hm?