c++
instructions are below
Sample output for Tuple::SIZE = 8, Tuple::MINVALUE - 1. Tuple::MAXVALUE = 100. BEGIN TESTSET (1,1,1,1,1,1,1,1) [2,3,4,5,6,7,8,9) (2,3,4,5,6,7,8,9) (99,3,4,5,6,7,8,2) (100,3,4,5,6,7,8,1) END TESTSET BEGIN TESTSORT {8,7,6,5,4,3,2,1) {1,2,3,4,5,6,7,8) (100,2,3,4,5,6,7,8) [2,3,4,5,6,7,8,100) END TESTSORT BEGIN TESTREVERSE {50,51,52,53,54,55,56,57) (57,56,55,54,53,52,51,50) (50,51,52,53,54,55,56,57) END TESTREVERSE BEGIN TESTROTATE (1,2,3,4,5,6,7,8) [2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) (8,1,2,3,4,5,6,7) (7,8,1,2,3,4,5,6) {6,7,8,1,2,3,4,5) (5,6,7,8,1,2,3,4) (4,5,6,7,8,1,2,3} 13,4,5,6,7,8,1,2) [2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) (8,1,2,3,4,5,6,7) 7,8,1,2,3,4,5,6) (6,7,8,1,2,3,4,5) (5,6,7,8,1,2,3,4) (4,5,6,7,8,1,2,3) (3,4,5,6,7,8,1,2) (2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) END TESTROTATE Your code must work with any positive value of Tuple::SIZE and different values of Tuple:MINVALUE. Tuple::MAXVALUE. nce 20 Sec 071 (30534) > Files > Tuple.cpp Tuple.cpp Download Tuple.cpp (569 Bytes) Page 1 of 2 o #include "Tuple.h" #include
using namespace std; Tuple:: Tuple(int init) { int Tuple::get(int n) const { void Tuple::set(int position, int value) { void Tuple::rotate(int amount) { void Tuple: : reverse() { PrtScu void Tuple: treverse() { void Tuple: :print() const { double Tuple::getAverage() const { void Tuple: :sort() { bool Tuple::equal(const Tuples c) const { bool Tuple:equalBags(const Tuples t) const { wifndef TUPLE H wdefine TUPLE_H I! A Tuple represents a sequenc MAXVALUE. 1/ The number of ites constant II The items are accessed by position is SIZE class Tuple public: static const int SIZE that SIZE is always 5. static const int MINV private: SS SE w 0 195 int items SIZE and so on. first item, Itens[1] holds second iten public: Tuple(int init to init. initialize the tuple object with an itens equal lize the // Return the nth item for any in the range (1... SIZE) // Remember: The nth item is stored at index n-1, NOT index n. 1/ For n SIZE, return the last item. int get(int n) const; // Assuning v in range (MINVALUE... MAXVALUE) and n in range (1... SIZE) // setin ) sets the nth iten to v. // For n in range and v MAXVALUE, setin, v) is equivalent to setin, MAXVALUE) 1/ For n out of range set(nv) does nothing, regardless of what vis. void set(int n, int v): // Rotate 1ten forward by the given amount. For example, if amount - 3 // then fourth will get the original value of first, first will get the original value of second 77 second will get the original value of third and third will get the original value of fourth. // If amount is a multiple of SIZE or negative then rotate will do nothing // If amount is bigger than SIZE, then rotate by amount * SIZE. void rotate(int amount); void reverse(); (87.5, 14, 10). // reverse the order of elements e... (10, 14, 5, 87) --> void print() const; // print values in braces, separated by connas e.g. (10,20,30,40). then print endl. double getAverage() const; // return the average of all items in the Tuple. // arrange the value in ascending order. Use bubblesort void sort(); selection sort. bool equal(const Tuple& t) const; // return true iff the two Tuples contain the same sequence of values. 7/ Return true if the current object and t contain the same multiset ("bag of items. // That means, for any value v, if v occurs k times in one object // then v must also occur k times in the other object. // Hint: Create a sorted version of each Tuple and compare for equality bool equalBags(const Tuple& t) const; Sample output for Tuple::SIZE = 8, Tuple::MINVALUE - 1. Tuple::MAXVALUE = 100. BEGIN TESTSET (1,1,1,1,1,1,1,1) [2,3,4,5,6,7,8,9) (2,3,4,5,6,7,8,9) (99,3,4,5,6,7,8,2) (100,3,4,5,6,7,8,1) END TESTSET BEGIN TESTSORT {8,7,6,5,4,3,2,1) {1,2,3,4,5,6,7,8) (100,2,3,4,5,6,7,8) [2,3,4,5,6,7,8,100) END TESTSORT BEGIN TESTREVERSE {50,51,52,53,54,55,56,57) (57,56,55,54,53,52,51,50) (50,51,52,53,54,55,56,57) END TESTREVERSE BEGIN TESTROTATE (1,2,3,4,5,6,7,8) [2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) (8,1,2,3,4,5,6,7) (7,8,1,2,3,4,5,6) {6,7,8,1,2,3,4,5) (5,6,7,8,1,2,3,4) (4,5,6,7,8,1,2,3} 13,4,5,6,7,8,1,2) [2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) (8,1,2,3,4,5,6,7) 7,8,1,2,3,4,5,6) (6,7,8,1,2,3,4,5) (5,6,7,8,1,2,3,4) (4,5,6,7,8,1,2,3) (3,4,5,6,7,8,1,2) (2,3,4,5,6,7,8,1) {1,2,3,4,5,6,7,8) END TESTROTATE Your code must work with any positive value of Tuple::SIZE and different values of Tuple:MINVALUE. Tuple::MAXVALUE. nce 20 Sec 071 (30534) > Files > Tuple.cpp Tuple.cpp Download Tuple.cpp (569 Bytes) Page 1 of 2 o #include "Tuple.h" #include using namespace std; Tuple:: Tuple(int init) { int Tuple::get(int n) const { void Tuple::set(int position, int value) { void Tuple::rotate(int amount) { void Tuple: : reverse() { PrtScu void Tuple: treverse() { void Tuple: :print() const { double Tuple::getAverage() const { void Tuple: :sort() { bool Tuple::equal(const Tuples c) const { bool Tuple:equalBags(const Tuples t) const { wifndef TUPLE H wdefine TUPLE_H I! A Tuple represents a sequenc MAXVALUE. 1/ The number of ites constant II The items are accessed by position is SIZE class Tuple public: static const int SIZE that SIZE is always 5. static const int MINV private: SS SE w 0 195 int items SIZE and so on. first item, Itens[1] holds second iten public: Tuple(int init to init. initialize the tuple object with an itens equal lize the // Return the nth item for any in the range (1... SIZE) // Remember: The nth item is stored at index n-1, NOT index n. 1/ For n SIZE, return the last item. int get(int n) const; // Assuning v in range (MINVALUE... MAXVALUE) and n in range (1... SIZE) // setin ) sets the nth iten to v. // For n in range and v MAXVALUE, setin, v) is equivalent to setin, MAXVALUE) 1/ For n out of range set(nv) does nothing, regardless of what vis. void set(int n, int v): // Rotate 1ten forward by the given amount. For example, if amount - 3 // then fourth will get the original value of first, first will get the original value of second 77 second will get the original value of third and third will get the original value of fourth. // If amount is a multiple of SIZE or negative then rotate will do nothing // If amount is bigger than SIZE, then rotate by amount * SIZE. void rotate(int amount); void reverse(); (87.5, 14, 10). // reverse the order of elements e... (10, 14, 5, 87) --> void print() const; // print values in braces, separated by connas e.g. (10,20,30,40). then print endl. double getAverage() const; // return the average of all items in the Tuple. // arrange the value in ascending order. Use bubblesort void sort(); selection sort. bool equal(const Tuple& t) const; // return true iff the two Tuples contain the same sequence of values. 7/ Return true if the current object and t contain the same multiset ("bag of items. // That means, for any value v, if v occurs k times in one object // then v must also occur k times in the other object. // Hint: Create a sorted version of each Tuple and compare for equality bool equalBags(const Tuple& t) const