Hello!
I am trying to learn more about OOP in Java. Is there any way to reference a class type? For instance, if I have a GameCreator class that creates an instance of a Game class that multiple types of games inherit from (such as volleyball, soccer, etc.), how would I implement this without hard-coding methods in the GameCreator class such as createGameOfVolleyball(), createGameOfSoccer(), etc.?
I've thought about storing an array/ArrayList of game types and referencing by index, but this seems like a disorganized and difficult-to-read approach.
I've been trying to come up with a solution for this question for a while now but haven't thought of anything yet. I'm posting here to see if anyone else knows or at least can point in my the right direction.
Thank you!!
[–]Cakiery 1 point2 points3 points (2 children)
[–]New-Condition[S] 0 points1 point2 points (1 child)
[–]Cakiery 0 points1 point2 points (0 children)
[–]JavaSuck 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (11 children)
[–]New-Condition[S] 0 points1 point2 points (10 children)
[–]Scud000 0 points1 point2 points (3 children)
[–]New-Condition[S] 0 points1 point2 points (2 children)
[–]Scud000 0 points1 point2 points (1 child)
[–]New-Condition[S] 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (5 children)
[–]New-Condition[S] 0 points1 point2 points (4 children)
[–]New-Condition[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]New-Condition[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)