Question: Help to fix this program! Lottery.h ***************************************************************************** #ifndef LOTTERY_H #define LOTTERY_H #include #include #include #define SIZE 5 #define MAX_RANGE 10 #define MIN_RANGE 5 using namespace

Help to fix this program!

Help to fix this program! Lottery.h ***************************************************************************** #ifndef LOTTERY_H #define LOTTERY_H #include

Lottery.h

*****************************************************************************

#ifndef LOTTERY_H #define LOTTERY_H #include #include #include

#define SIZE 5 #define MAX_RANGE 10 #define MIN_RANGE 5 using namespace std;

class Lottery { protected: int lottery[SIZE]; public: Lottery(); ~Lottery(); virtual void intro(); virtual void generateNumbers(); int findMatches(Lottery &) ; friend ostream &operator>(istream &, Lottery &); bool operator==(Lottery &); };

#endif

Lottery.cpp

**************************************************************************

#include #include #include #include "Lottery.h" using namespace std;

Lottery::Lottery(){} Lottery::~Lottery(){}

void Lottery::intro() { cout

void Lottery::generateNumbers() { srand((unsigned)time(NULL)); for (int i = 0; i

int Lottery::findMatches(Lottery &obj) { int matches = 0; for (int i = 0; i

ostream &operator

istream &operator>>(istream &is, Lottery &obj) { for (int i = 0; i > temp; while (is.fail() || (int)temp != temp || temp 9 || getchar() != ' ') { cout ::max(), ' '); is >> temp; cout

bool Lottery::operator==(Lottery &right) { for (int i = 0; i

SuperLoto.h

***************************************************************************

#ifndef SUPERLOTO_H #define SUPERLOTO_H #include #include "Lottery.h" using namespace std;

class SuperLoto : public Lottery{ protected: int superLoto; public: void intro(); void generateNumbers(); }; #endif

SuperLoto.cpp

********************************************************************

#include #include #include #include "Lottery.h" #include "SuperLoto.h" using namespace std;

void SuperLoto:: intro() { cout

void SuperLoto::generateNumbers() { srand((unsigned)time(NULL)); superLoto = 0 + rand() % MIN_RANGE; cout

Main.cpp

*****************************************************************************

#include #include #include #include "Lottery.h" #include "SuperLoto.h" using namespace std;

int main() { for(bool reRun = true; reRun != false;) { char choice; //create an object Lottery player, automate; SuperLoto super; // virtual function call through reference Lottery& playerR = player; // the type of playerR is Lottery* Lottery& superR = super; // the type of superR is Lottery* as well automate.generateNumbers(); // generateNumbers base class super.generateNumbers(); // generateNumbers dervived class

int numMatches; // Number of matches player.intro(); // prints base class super.intro(); // prints dervived class

cin >> player; cout

numMatches = player.findMatches(automate); cout

if (player==automate) cout > choice; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!