Programming a Role Playing Game - Part 1: The Player
In the first part we created a Journal object. Now we need to implement the class.
I put it in the models.journal package to keep everything organized. The journal at this stage is pretty simple, we will deal with the UI in another class. Here we will make an Array of the Quest class. You could add a Quest to the array by calling getQuests().add() but I made a convenience method for readability.
And now we have to create the Quest class.
The class is pretty self explanatory if you know Java or other object-oriented languages already. The attribute priority is used in sorting. And attribute finished is also used to move the quest to the "Done Quests" -tab in the UI.
We can now add some test quests to the Journal from the Player class.
Since the journal in the Player class is static, we must access it like that. This would be the initial quest that shows in the player's journal, with title, description and the 1st priority.
That's all for now, more to come. Thanks for reading!
Code formatted with hilite.me