Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 //printf and NULL #include #include //srand and rand #include #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

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

Step: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions