Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

4. Identify the stage of the road of trials in The Wizard of Oz.

Answered: 1 week ago

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago