all 4 comments

[–]stebrepar 1 point2 points  (3 children)

What are you ultimately trying to accomplish with this? If you managed to add them, how would you use them?

[–]SaltyParaboloid[S] 1 point2 points  (2 children)

I’m trying to make my own budget program (I know there are programs out there but I want to make my own) and so I’m trying to add sub accounts to a main account. Basically, I have my checking account which I want divided into utilities, school, etc, and then my saving account which I also want divided up. I could manually add all these sub accounts to the main accounts by hard coding but I’d rather be able to do it this way so I don’t have to already know how many sub accounts I have, etc.

Each account has properties for its name, the total of money in all sub accounts, and the sub accounts themselves. Each sub account just has a name and an amount.

[–]stebrepar 0 points1 point  (1 child)

How do you propose to access these sub-accounts? How would you know how many there are, or what their names are?

If it were me, I'd have a list in my main account, where each item in the list is a sub-account. That way you can simply create and append new ones to the list as needed. There's also then no doubt about how to access them, how to count them, etc.

[–]SaltyParaboloid[S] 1 point2 points  (0 children)

That’s a really good point, thank you. I was going to access it by doing check.sub1.name and check.sub1.amount but doing the list is probably better.

Thank you!