Please do this program make sure it work. Please separate this project into 3 fi
ID: 3679568 • Letter: P
Question
Please do this program make sure it work. Please separate this project into 3 files 1) interface.h 2) implementation.cpp 3)testing.cpp
. please make sure you read the grading criteria in the picture. please do not include all your function in main. main should be in the 3rd file. please do not have all the codes in main. you need to have just the object instantiation and function calling.
make sure it works
Chegg Study | Guided Sol ·Homepage-CS 1119-91 /D CS-1119-91-CPP-Program ziad × × × C file:///C:/Users/makho/Downloads/CS_1119-91 CPP Programming Spring 2016_Project_07.pdf CS 1119-91_CPP_Programming_Spring 2016_Project 07.pdf 112 CS 1119-91 C++ Programming Create a program that automatically picks and displays one set of six random numbers. The first five numbers must be unique whole numbers (no duplicates among them), and each of them must be greater than 0 and less than 70. The sixth number can be any whole number greater than 0 and less than 27 Ing Project 7 Your solution must be separated into, at least, three files (Interface, Implementation and Test).There should only be minimal code in the Test file, just enough to instantiate an object, and invoke the appropriate method(s). Submit your source file(s) to the drop box no later than the deadline (11:59 pm on Tuesday, March 22"d 2016). Late submission penalty: 25 points per day. Only.cpp and.h files will be accepted. If you submit other types of files, they will be rejected, and you'll receive no points. 11:42 PM Ask me anything 98% 3/18/2016Explanation / Answer
impl.h
#ifndef IMPL_H
#define IMPL_H
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
class RandomSet {
public:
// default constructor
RandomSet();
// converting set to proper string
string toString();
// get item at given index
int get(int);
private:
// to hold the set elements
int v[6];
string to_string(int num);
};
#endif // IMPL_H
impl.cpp
#include "impl.h"
#include <bits/stdc++.h>
using namespace std;
// implementing default constructor
RandomSet::RandomSet() {
// feed the seed to random number generator
srand(time(NULL));
// fill first 5 unique in [0, 70)
int count = 0;
while (count < 5) {
int item = rand() % 70;
bool isUnique = true;
for (int i = 0; i < 5; ++i) {
if (v[i] == item) {
isUnique = false;
break;
}
}
if (isUnique) {
v[count++] = item;
}
}
// set last 6th number in [0, 27)
v[count] = rand() % 27;
}
string RandomSet::toString() {
string set_string = "[";
for (int i = 0; i < 6; ++i) {
set_string += to_string(v[i]);
if (i != 5) set_string += ", ";
}
set_string += "]";
return set_string;
}
int RandomSet::get(int index) {
return v[index];
}
string RandomSet::to_string(int num) {
string s = "";
if (num == 0) return "0";
while (num > 0) {
int r = num % 10;
s += char('0' + r);
num /= 10;
}
return s;
}
main.cpp
#include "impl.h"
#include <bits/stdc++.h>
using namespace std;
int main() {
// instantiate and output array
RandomSet r;
cout << "SET: " + r.toString() << endl;
// get array
int v[6];
for (int i = 0; i < 6; ++i) v[i] = r.get(i);
// check for range of first 5
bool inRange = true;
for (int i = 0; i < 5; ++i) if (v[i] < 0 || v[i] >= 70) { inRange = false; break; }
if (!inRange) cout << "Failed: First 5 not in range [0, 70) ";
else cout << "Passed: First 5 in range [0, 70) ";
// check for last number in range [0, 27)
inRange = true;
if (v[5] < 0 || v[5] >= 27) inRange = false;
if (!inRange) cout << "Failed: Last not in range [0, 27) ";
else cout << "Passed: Last in range [0, 27) ";
// check for uniqueness of first 5
bool areTheyUnique = true;
for (int i = 0; i < 5; ++i) {
for (int j = i + 1; j < 5; ++j) {
if (v[i] == v[j]) {
areTheyUnique = false;
break;
}
}
}
if (!areTheyUnique) cout << "Failed: First 5 are not unique ";
else cout << "Passed: First 5 are unique ";
return 0;
}