Good morning. I have recently started studying C# with the book The C# Player's Guide. To learn more effectively, I am using AI to generate extra exercises in addition to the ones in the book, but I don't know if the ones from the AI are good enough.
Here's an example of one I had to do after finishing the chapter about loops to review the previous chapters
The Tavern Simulator (Boss Fight: Total Review)
You just finished a quest and decide to rest at the local tavern. The program must simulate your choices during the evening, managing your wallet and your stamina.
Coding Rules:
Change the console title to "Tavern Simulator".
Ask the player for their name and store it in a string.
Create two starting status variables:
coins = 50
energy = 100
Open a large while(true) loop that represents your time spent at the tavern. At the beginning of each loop iteration, clear the screen (Console.Clear()) and print the player's current stats like this (use colors!):
Name: [Player Name]
Coins: [X] (in Yellow)
Energy: [Y] (in Green)
Display a menu with these options:
1 - Buy a hot meal (Costs 15 coins, restores 30 energy).
2 - Buy a dwarven ale (Costs 5 coins, restores 10 energy).
3 - Go outside and chop wood (Earn 20 coins, costs 40 energy).
4 - Go to sleep (End the evening).
Read the user's input and use a switch statement to handle the 4 choices.
Conditional Logic (The if statements inside the switch):
If choice 1 or 2: check first if the player has enough coins! If they do, do the math (subtract coins, add energy) and print a success message. Else, print a red error message ("Not enough coins!").
If choice 3: check if the player has at least 40 energy! Otherwise, print an error message ("You are too tired!").
If choice 4: use the break command to escape the infinite loop.
(Optional but recommended): Add a Console.ReadKey(); after the success/error messages, so the user has time to read what happened before the Console.Clear() wipes the screen for the next turn.
Outside the loop (after the user goes to sleep), print a goodnight message: "Goodnight [Name], you finished the day with [X] coins and [Y] energy."