I have to code the game mastermind, but i only got halfway. I got the user input, 8 colors and the 3 different types of row. I just need help solving the duplication problem. the code that has been underlined below are the result to see if the random generator is working properly, which needs to be changed. I need to solve the duplication function if the user agrees to allowing duplicates. and the duplication of the same colors in the 3 different rows that are not suppose to have duplicates if the user says no, as well as the result of the correct resonse to the correct color with correct position. For example:   cout<<"2 are correct but 1 is in wrong position"<<endl; . here is a game on mastermind in case you dont know how to play: http://www.webgamesonline.com/mastermind/ /* * File: main.cpp* Author: Ethan Steppe* Created on July 19, 2016, 9:07 AM* Purpose: make a functioning mastermind game*/ //System Libraries Here#include <iostream>#include <cstdlib>#include <ctime>using namespace std; //User Libraries Here //Global Constants Only, No Global Variables//Like PI, e, Gravity, or conversions //Function Prototypes Hereint FourRow(int Frow);int SixRow(int Srow);int EightRow(int Erow);int Duplicate(int row); //Program Execution Begins Hereint main(int argc, char** argv) {//Declare all Variables Heresrand(static_cast<unsigned int>(time(0)));//Input or initialize values Hereint answer;int duplicate;//Process/Calculations Here//Output Located Herecout<<"Welcome to Mastermind!"<<endl;cout<<"What rows do you want to solve?"<<endl;cin>>answer;cout<<endl;cout<<"do you want to allow duplicates? Answer in y or n"<<endl;cin>>duplicate;cout<<"ALLLLRIGHT!! Here are the rules: you have to match the correct colors onto the correct position in order to win."<<endl;cout<<"If you failed for a total of 10 times. You LOSE!!"<<endl;if(answer==4){FourRow(4);}else if(answer==6){SixRow(6);}else{EightRow(8);} //Exitreturn 0;} FourRow(int Frow){const int COL=8;const int SIZE=8;int array[SIZE];char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};array[0]=rand()%4;//calculationsfor(int i=i;i<Frow;i++){for(int j=0;j<i;j++){do{array[i]=rand()%8;}while(array[i]==array[j]);}}cout<<endl;for(int i=0;i<Frow;i++){cout<<color[array[i]]<<" ";}cout<<endl;//amount of chances: 10 before losing}SixRow(int Srow){const int COL=8;const int SIZE=8;int array[SIZE];char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};array[0]=rand()%6; for(int i=i;i<Srow;i++){for(int j=0;j<i;j++){do{array[i]=rand()%8;}while(array[i]==array[j]);}}cout<<endl;for(int i=0;i<Srow;i++){cout<<color[array[i]]<<" ";}cout<<endl;} EightRow(int Erow){const int COL=8;const int SIZE=8;int array[SIZE];char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};array[0]=rand()%8; for(int i=i;i<Erow;i++){for(int j=0;j<i;j++){do{array[i]=rand()%8;}while(array[i]==array[j]);}}cout<<endl;for(int i=0;i<Erow;i++){cout<<color[array[i]]<<" ";}cout<<endl;} Duplicate(int row){}

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have to code the game mastermind, but i only got halfway. I got the user input, 8 colors and the 3 different types of row. I just need help solving the duplication problem. the code that has been underlined below are the result to see if the random generator is working properly, which needs to be changed. I need to solve the duplication function if the user agrees to allowing duplicates. and the duplication of the same colors in the 3 different rows that are not suppose to have duplicates if the user says no, as well as the result of the correct resonse to the correct color with correct position. For example:   cout<<"2 are correct but 1 is in wrong position"<<endl; . here is a game on mastermind in case you dont know how to play: http://www.webgamesonline.com/mastermind/

/*
* File: main.cpp
* Author: Ethan Steppe
* Created on July 19, 2016, 9:07 AM
* Purpose: make a functioning mastermind game
*/

//System Libraries Here
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

//User Libraries Here

//Global Constants Only, No Global Variables
//Like PI, e, Gravity, or conversions

//Function Prototypes Here
int FourRow(int Frow);
int SixRow(int Srow);
int EightRow(int Erow);
int Duplicate(int row);

//Program Execution Begins Here
int main(int argc, char** argv) {
//Declare all Variables Here
srand(static_cast<unsigned int>(time(0)));
//Input or initialize values Here
int answer;
int duplicate;

//Process/Calculations Here

//Output Located Here
cout<<"Welcome to Mastermind!"<<endl;
cout<<"What rows do you want to solve?"<<endl;
cin>>answer;

cout<<endl;
cout<<"do you want to allow duplicates? Answer in y or n"<<endl;
cin>>duplicate;
cout<<"ALLLLRIGHT!! Here are the rules: you have to match the correct colors onto the correct position in order to win."<<endl;
cout<<"If you failed for a total of 10 times. You LOSE!!"<<endl;

if(answer==4){
FourRow(4);
}
else if(answer==6){
SixRow(6);
}
else{
EightRow(8);
}

//Exit
return 0;
}

FourRow(int Frow){
const int COL=8;
const int SIZE=8;
int array[SIZE];
char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};
array[0]=rand()%4;
//calculations
for(int i=i;i<Frow;i++){
for(int j=0;j<i;j++){
do{
array[i]=rand()%8;
}while(array[i]==array[j]);
}
}
cout<<endl;
for(int i=0;i<Frow;i++){
cout<<color[array[i]]<<" ";
}
cout<<endl;
//amount of chances: 10 before losing

}

SixRow(int Srow){
const int COL=8;
const int SIZE=8;
int array[SIZE];
char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};
array[0]=rand()%6;
for(int i=i;i<Srow;i++){
for(int j=0;j<i;j++){
do{
array[i]=rand()%8;
}while(array[i]==array[j]);
}
}
cout<<endl;
for(int i=0;i<Srow;i++){
cout<<color[array[i]]<<" ";
}
cout<<endl;
}

EightRow(int Erow){
const int COL=8;
const int SIZE=8;
int array[SIZE];
char color[SIZE][COL]={"Red","Green","Blue","Yellow","Brown","Black","White","Orange"};
array[0]=rand()%8;
for(int i=i;i<Erow;i++){
for(int j=0;j<i;j++){
do{
array[i]=rand()%8;
}while(array[i]==array[j]);
}
}
cout<<endl;
for(int i=0;i<Erow;i++){
cout<<color[array[i]]<<" ";
}
cout<<endl;
}

Duplicate(int row){

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education