Hello everyone, I am new to Kotlin so I am current...
# getting-started
h
Hello everyone, I am new to Kotlin so I am currently exploring the niche things in it, I came up with the idea to code a "crude" CLI based game in kotlin as it would have me use a lot of things from enums to data classes in it so i saw fit for it to make it but I wanted some opinion on something I am trying to implement. I am planning to create a global instance of MenuLoader class which will be used to display the menu and handle the user inputs, but I want to design it so that it can handle a types objects that can be further used to either generate new responses or do something to the game, is there a way for me to be able to create a data class that is not tightly coupled to only a specific type of object but rather is able to store and handle multiple type of object (i.e DialogGenerator, ActionClass, etc..)
w
Sounds like generic types to me, if it's not. Could you show in pseudo code what you would like?
1
🙌 1
h
I have not explored generics at all so will explore and see if they are a fit for this
I wanted it to be something like Menu • Go to shop1 • Go to House • Talk To NPC-A • Challenge BadGuy-A • Open Map i want it so that i can select and option and the option is tied to a different sort of object that will do what it is designed to do
b
I don't understand the problem entirely, but regarding the menu items it might be beneficial to look into the Command design pattern.
🙌 1
h
actually this is exactly what i wanted to have from the looks of it thanks! ^-^
b
@HighTide I’m glad if I could help, good luck! 😉