Question
I wrote this code on horse race simulation but how can i make it work with procedural style instead of using objects. #include //printf and
I wrote this code on horse race simulation but how can i make it work with procedural style instead of using objects.
#include
using namespace std;
class Horse { public: int place; bool bWon; Horse(const int& iPos = 0) : place(iPos), bWon(false) {} void move_horse() { place += rand() % 2; } void win() { bWon = true; } int getplace(){ return place; } };
class Horse_Race{ public: Horse *h; int length; int iCount; bool bEnd; int winner; Horse_Race(int iHorses = 2, int iLen = 10){ iCount = iHorses; h = new Horse[iCount]; length = iLen; bEnd = false; } Horse_Race() { delete[] h; h = NULL; } void print() { cout << endl; for (int i = 0; i < iCount; i++) { for (int j = 0; j < h[i].getplace(); j++) { cout << "."; } cout << "(" << i << ")"; for (int l=h[i].getplace(); l < 15; l++) { cout << "."; } cout<
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