Question: #include SlotMachine.h #include #include void SlotMachine::setNumSymbols(int numSymbols) { //only called at construction srand(time(NULL)); this->numSymbols = numSymbols; } bool SlotMachine::threeOfAKind() const { bool win = false;

#include "SlotMachine.h" #include #include

void SlotMachine::setNumSymbols(int numSymbols) { //only called at construction srand(time(NULL)); this->numSymbols = numSymbols; }

bool SlotMachine::threeOfAKind() const { bool win = false; if (reels[0] == reels[1] && reels[1] == reels[2]) { win = true; std::cout << "3 of a kind! "; } return win; }

bool SlotMachine::twoOfAKind() const { bool winner = false; if (reels[0] == reels[1] || reels[1] == reels[2] || reels[2] == reels[0]) { winner = true; std::cout << "2 of a kind! "; } return winner; }

bool SlotMachine::straight() const { bool win = false; if (reels[0] + 1 == reels[1] && reels[1] + 1 == reels[2]) { win = true; std::cout << "Straight! "; } return win; }

SlotMachine::SlotMachine(int numSymbols) { spinCt = 0; setNumSymbols(numSymbols); }

int SlotMachine::getNumSymbols() const { return numSymbols; }

int SlotMachine::getSpinCt() const { return spinCt; }

void SlotMachine::pullLever() { //spin each reel reels[0] = rand() % numSymbols; reels[1] = rand() % numSymbols; reels[2] = rand() % numSymbols; //count this spin spinCt++; }

bool SlotMachine::isWinner() const { return threeOfAKind() || straight(); }

void SlotMachine::display() const { std::cout << "-------------------" << std::endl; std::cout << "| " << reels[0] << " | " << reels[1] << " | " << reels[2] << " | " << std::endl; std::cout << "-------------------" << std::endl; }

#include

class SlotMachine { private: int reels[3]; int numSymbols; int spinCt; void setNumSymbols(int); bool threeOfAKind()const; bool twoOfAKind()const; bool straight()const; public: SlotMachine() { setNumSymbols(10); spinCt = 0; } SlotMachine(int numSymbols); int getNumSymbols()const; int getSpinCt()const; void pullLever(); bool isWinner()const; void display()const; };

#endif

Make a UML diagram and a flowcharts. And explain everything about the UML and the flowcharts

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!