Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This project is continuation Code as below. In this assignment you will use inhe

ID: 3815521 • Letter: T

Question

This project is continuation Code as below. In this assignment you will use inheritance, Interfaces, abstract classes and polymorphism to generate random numbers as easy pick for two different lotto games: Lotto and Small Lotto.  

#include<iostream>
#include <cstdlib>
using namespace std;
class GameMenu
{
   public:
   int numbers[5], wildNum;
   int arraySize;
   GameMenu(){
       /*Initiate with default value*/
       arraySize = 0;
   }
   GameMenu(int size){ //--overload constructor
       /*Initiate with value*/
       arraySize = size;
   }
   void generateLottoNumbers(){
       for (int i = 0; i < arraySize; ++i) {
           numbers[i] = rand();
       }
   }
   void display(){
       for(int inc=0; inc<arraySize; inc++)
       {
           cout << numbers[inc];
           if (inc != arraySize-1)
               cout << ",";
       }
       cout << endl;
   }
};
class Lotto:public GameMenu
{
    public:
       Lotto() : GameMenu(5){}//-- super class contructor value will be assigned here, when subclass call made
       void generateLottoNumbers(){ //-- method override
           for (int i = 0; i < arraySize; ++i) {
               numbers[i] = rand() % 54 + 1;
           }
       }
       void getWildNumber(){
           int random_number = numbers[rand() % arraySize];
           if (random_number > 1 and random_number < 40){
               wildNum = random_number;
           }
           cout << "Your wild numbers is: " << wildNum << endl;
       }
};
class SmallLotto:public GameMenu
{
    public:
   SmallLotto() : GameMenu(5){}//-- super class contructor value will be assigned here, when subclass call made
   void generateLottoNumbers(){ //-- method override
       for (int i = 0; i < arraySize; ++i) {
           numbers[i] = rand() % 52 + 1;
       }
   }
};
class CheckGame{
   public:
    int main(){
        int ch;
       Lotto l1;
       SmallLotto l2;
       do{
           cout << "What game do you want to play?" << endl;
           cout << "1. Lottp" << " " << "2. Small lotto" << endl << "3. Quit" << endl;
           cin >> ch;
           if (ch == 1){
               l1.generateLottoNumbers();
               cout << "Your lotto numbers:";
               l1.display();
               l1.getWildNumber();
           }
           if (ch == 2){
               l2.generateLottoNumbers();
               cout << "Your small lotto numbers:";
               l2.display();
           }
       }while(ch != 3);
       return 0;
    }
};
int main()
{
   CheckGame cg;
   cg.main();
   return 0;
}

First randomly generate what game to play The Generate random numbers needed for the game and Store the numbers in an array or arrayList as objects. Write the necessary code to make sure that none of these numbers is repeated (e.g., first five numbers are unique). No number of the first 5 numbers can be repeated more than once. For the lotto game, generate a number between 1 and 40 (called Wild number). This number is generated independently from the 5 numbers and you don't check this number for duplicates Your code must meet the following requirements 1. Use inheritance, interfaces, abstract classes and polymorphism in your code. 2. Your code must consist of at and one interface and at least 4 different classes: one with the main method, second as the super class (abstract) and two classes as subclasses. Make sure that the abstract class has at least one abstract method. 3. Provide good documentation of your code. Each method must be specialized and does a very specific work (has a high level of cohesion and very reusable) 5. Your code will as the user to generate another 10 random games or not. It will not terminate until the user indicate so by selecting an option that means quit. Your print the numbers for all the randomly generated games and it will then ask the use do you want to play more games or quit? 6. Use enhanced for loop as you see fit 7. Use overloaded constructors. Use at least one override method. 8. 9. The user has the option to play at least 2 different games: For example: Lotto and SmallLotto

Explanation / Answer

#include<iostream>
#include <cstdlib>
using namespace std;
class GameMenu
{
public:
int numbers[5], wildNum;
int arraySize;
GameMenu(){
  
arraySize = 0;
}
GameMenu(int size){

arraySize = size;
}
void generateLottoNumbers(){
for (int i = 0; i < arraySize; ++i) {
numbers[i] = rand();
}
}
void display(){
for(int inc=0; inc<arraySize; inc++)
{
cout << numbers[inc];
if (inc != arraySize-1)
cout << ",";
}
cout << endl;
}
};
class Lotto:public GameMenu
{
public:
Lotto() : GameMenu(5){}
void generateLottoNumbers(){
for (int i = 0; i < arraySize; ++i) {
numbers[i] = rand() % 54 + 1;
}
}
void getWildNumber(){
int random_number = numbers[rand() % arraySize];
if (random_number > 1 and random_number < 40){
wildNum = random_number;
}
cout << "Your wild numbers is: " << wildNum << endl;
}
};
class SmallLotto:public GameMenu
{
public:
SmallLotto() : GameMenu(5){}
void generateLottoNumbers(){
for (int i = 0; i < arraySize; ++i) {
numbers[i] = rand() % 52 + 1;
}
}
};
class CheckGame{
public:
int main(){
int ch;
Lotto l1;
SmallLotto l2;
cout << "What game do you want to play?" << endl;
cout << "1. Lottp" << " " << "2. Small lotto" << endl << "3. Quit" << endl;
cin >> ch;
do{

  
if (ch == 1){
l1.generateLottoNumbers();
cout << "Your lotto numbers:";
l1.display();
l1.getWildNumber();
}
if (ch == 2){
l2.generateLottoNumbers();
cout << "Your small lotto numbers:";
l2.display();
}
}while(ch != 3);
return 0;
}
};
int main()
{
CheckGame cg;
cg.main();
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote