I have a Create function in one type (TPlayer) that I want to call and have it access a create function in another type (TBall) so I can add it to a list.
I have included an example of it here, which seems to work, but I have a couple of questions
1. NewBall = NewBall.Create(2) - just doesnt seem right- creating a local TBall which then calls its method 'Create', which then creates another local TBall, initialises it and returns it doesnt seem nice at all!
2. Most of the OOP code I see has a create function but I'm wondering why if New is always called when new object is created - why cant all the setting up of the object just go into the new Method? Is it because you can only call a method if the object exists otherwise you have to create the object in a function?
I'm basically looking for the cleanest way of doing things. Thanks
|