Question
Build a program that simulates a horse race. You will have a track of 15 units long, and five horses. On each turn, each horse
Build a program that simulates a horse race. You will have a track of 15 units long, and five horses. On each turn, each horse will 'flip a coin' (Right, I don't know how horses flip coins either, but go with me on this.) Half the time, the horse will move forward one unit, and half the time it will stay in the same place. On each turn, you will see the track with the positions of the five horses, and dots for all the other positions. The race ends when one of the horses passes the finish line. You will have two objects in the game. There will be an array of five horse objects. The horse will 'know' how to advance according to a random flip, and to return its position. The other primary entity in this game is the race (or the track, if you prefer.) This object will contain a series of horses. It will also have the ability to start the race. When the race is running, the race class will 'tell' each horse to advance, and will print out a track diagram showing the relative positions of the horses. While you have already written this program in a procedural fashion, this program is a perfect candidate for the object-oriented paradigm. Please use the UML diagram I created as a starting point: oophorse.jpg
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started