Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i will add the program that needs to be editied. its cpp. please help asap!! its due soon. 2000-21090 , Assignments > The object of

i will add the program that needs to be editied. its cpp.
please help asap!! its due soon. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
2000-21090 , Assignments > The object of Horses (A4) The Object of Horses (A4) Due Friday by 11:59pm Points 100 Overview Use the principles of Object Oriented Design (OOD) and Object Oriented Programming (OOP) to re-build the horseRace assignment using object-oriented programming. Each horse will be an object, and the race will be another object that contains a list of horses and manages the race. Along the way, you will experiment with UML, create classes, review access modifiers, build member variables, add access methods, and create constructors. The Project Build a program that simulates a horse race. The race works just like the last assignment, and the user may not ever see the difference. But this time, the underlying design will use objects. 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. In this case we may do automated testing against your program. In order to accommodate this you will prompt (ask for input) for a random seed and use it to seed your random number generator. This will allow you to test your program against several seeds. And we may test your program with a series of these random seeds. While this will not be your entire grade, but your ability to pass these tests could be a consideration in your grade. This is a common industry practice and one we will try to introduce you. Sample Run You can find an HTML5 version here: http://cs.jupui.edu.aharris/240/horseRace.html Note that you will not need the automation feature nor a GUI. This just gives you an idea of the race concept. Here is a sample run of the program: Code Organization 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: Race 1 5 -h: Horse] - Length: int +Race() Race(Length:int) +printLane (horseNum:int) : void +start(): void 16 Horse -position: int +Horse() +advance(): void 1+get Position(): int Programming Methodology This program must compile on Tesla. You will need to create a header file and a cpp file for each object, as well as a main.cpp. You will also need to create a make file to compile and run your program. You will be turning this program in using the IU github system. It is not necessary to create a GUI for this project. Since this is an exercise in OOP programming, you are expected to create at least two classes, as indicated in the class diagram provided above. All the methods and member variables necessary are listed in the UML diagram, but you might need to create other local variables inside your methods. There are other legitimate ways to organize this data, but this is one of the simpler techniques, Tips You will need two classes: each will have a header and a cpp file. You will also need a main.cpp file. do not include namespace std Your make file should have a target for each object as well as the main target to build the final executable. Your make file should also include clean and run targets. The horse class will need to utilize random number generation. I included an example of this with the last homework exercise, but you may still need to look up how to generate a random number in C++. Don't forget the srando function to ensure you get a different random sequence on each run of the program, Each class will need a simple constructor. (My version of Race actually has two constructors.) Remember that every class should have a null parameter constructor. Also, remember that the main point of a constructor is to initialize Here is a sample run of the program: Please enter a random seed: 700 .8. .2... 3.. 4. .1.. ...0.. ...2.. . ...4 0. ... Here is the C++ code. #include #include using namespace std; void racelint& hi int& h2, int& h3, int& h4, int& h5X iffrand(962-1) h1==1: if(rand(962-1) 21: if(rand()%21) 3+=1; if(rand(%2== 1) h4+1; iftrand1%2==1) h5-=1: > void display_race_tracklint pos, int horseNum) for(int i=1;i> seed: srand seed inthl.pos = 0, 12. posu, h3_posu 0,54_poso, h5_pos=0; while(hi_post15882_pos1588 h3_pos 15)cout15)cout15 cout15)cout The object of Horses (A4) The Object of Horses (A4) Due Friday by 11:59pm Points 100 Overview Use the principles of Object Oriented Design (OOD) and Object Oriented Programming (OOP) to re-build the horseRace assignment using object-oriented programming. Each horse will be an object, and the race will be another object that contains a list of horses and manages the race. Along the way, you will experiment with UML, create classes, review access modifiers, build member variables, add access methods, and create constructors. The Project Build a program that simulates a horse race. The race works just like the last assignment, and the user may not ever see the difference. But this time, the underlying design will use objects. 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. In this case we may do automated testing against your program. In order to accommodate this you will prompt (ask for input) for a random seed and use it to seed your random number generator. This will allow you to test your program against several seeds. And we may test your program with a series of these random seeds. While this will not be your entire grade, but your ability to pass these tests could be a consideration in your grade. This is a common industry practice and one we will try to introduce you. Sample Run You can find an HTML5 version here: http://cs.jupui.edu.aharris/240/horseRace.html Note that you will not need the automation feature nor a GUI. This just gives you an idea of the race concept. Here is a sample run of the program: Code Organization 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: Race 1 5 -h: Horse] - Length: int +Race() Race(Length:int) +printLane (horseNum:int) : void +start(): void 16 Horse -position: int +Horse() +advance(): void 1+get Position(): int Programming Methodology This program must compile on Tesla. You will need to create a header file and a cpp file for each object, as well as a main.cpp. You will also need to create a make file to compile and run your program. You will be turning this program in using the IU github system. It is not necessary to create a GUI for this project. Since this is an exercise in OOP programming, you are expected to create at least two classes, as indicated in the class diagram provided above. All the methods and member variables necessary are listed in the UML diagram, but you might need to create other local variables inside your methods. There are other legitimate ways to organize this data, but this is one of the simpler techniques, Tips You will need two classes: each will have a header and a cpp file. You will also need a main.cpp file. do not include namespace std Your make file should have a target for each object as well as the main target to build the final executable. Your make file should also include clean and run targets. The horse class will need to utilize random number generation. I included an example of this with the last homework exercise, but you may still need to look up how to generate a random number in C++. Don't forget the srando function to ensure you get a different random sequence on each run of the program, Each class will need a simple constructor. (My version of Race actually has two constructors.) Remember that every class should have a null parameter constructor. Also, remember that the main point of a constructor is to initialize Here is a sample run of the program: Please enter a random seed: 700 .8. .2... 3.. 4. .1.. ...0.. ...2.. . ...4 0. ... Here is the C++ code. #include #include using namespace std; void racelint& hi int& h2, int& h3, int& h4, int& h5X iffrand(962-1) h1==1: if(rand(962-1) 21: if(rand()%21) 3+=1; if(rand(%2== 1) h4+1; iftrand1%2==1) h5-=1: > void display_race_tracklint pos, int horseNum) for(int i=1;i> seed: srand seed inthl.pos = 0, 12. posu, h3_posu 0,54_poso, h5_pos=0; while(hi_post15882_pos1588 h3_pos 15)cout15)cout15 cout15)cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Do you have any "characters" in your family?

Answered: 1 week ago