I have been coding for a year but I’ve only been introduced and taught in lesson about OOP recently.
I posted a question earlier and somebody said that my program would be a lot better off using a player Class
I was wondering if it is of standard convention to use an object array?
So I need 10 players in my program. Is it okay to have an array of the Class Player with 10 instances? Or is this bad?
Thank you for your time.
It depends on how you plan on using the objects. There is certainly no problem at all creating a array of 10 Player objects. Another option, which may or may not be relevant to your program, could be to create an additional class that contains this array of 10 player instances (maybe call it “Team”?). This would make sense if you want to define methods or members that relate to the 10 players, such as wins/losses, or something of that nature.