I have homework in which I should imitate a game in which you have a chest and some objects (weapons, herbs, etc).
I need to create 2 classes - `Chest`(containing array `[Inventory]` and functions to append and remove) and `Inventory`(containing list of objects) and then pass `Inventory` to `Chest` as an array.
Later I need to create sub-classes for `Inventory`, through which I will add or delete objects to/from the `Chest`.
I tried to write some code, but it looks completely wrong even for a beginner like me.
How can I make this work?
class Inventory {
var plant = ""
var weapon = ""
var questObjects = ""
var pants = ""
}
class Chest {
var inventory: [Inventory]
}
class Inv2: Inventory {
var plant2 = "oak"
func append() {
inventory.append(contentsOf: plant)
}
}