Next, we’re going to improve the UX by displaying the current list of producers.
We’ll implement the function
updateProducerList(term, state) in
- It should print the list of producers, each on the new line starting from line 5.
- It should only print the producers where the
countis greater than 0, plus one producer with the 0 count, to show the user what’s their next objective.
- The output format should be like this:
Miner: 2 | Production per second: 0.1 | Cost: 12.8
Adventurer: 0 | Production per second: 1.0 | Cost: 100
- Production per second and cost should be rounded to a one digit after the decimal point.
updateProducerList should be called from
handleKeyPress every time there’s a need for it.
Good examples might be the transition from the initial welcome message in
checkInitCompleted or a purchase of a new producer.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.