Two cars are racing. A function carRace needs to be designed.
Both drivers start with a distance of 0.
In a loop, each driver's distance is updated by a random value between 1 and 20m.
While both drivers have not reached 200m, the race continues!
The first driver to reach 200m is the winner.
A coder has been messing with some ideas to code the solution but the lines are in the incorrect sequence. Reorder the code so that the function behaves as expected.
Create a new project called TheCarRace and design and test your solution. Does it work as expected?
Type your code into your IDE and run it. Fix any syntax errors that appear.
Think about this game. Can you find a way to adapt it to make it more interesting?
This may involve adding code to the main function, the carRace function, or designing a new function which performs a specific task when it is called!
Be creative! What could possibly go wrong?!
Be creative. Try to imagine what you want to happen and then try to make it happen.
You may have to do some research.
You can use ChatGPT to get ideas - but don't rely on it for solutions!