/*************************************************************** CSCI 240 Assignment 9 Spring 2025 Programmer: Section: Date Due: Purpose: ***************************************************************/ #include #include using namespace std; //Place Vector class definition here int main() { int slacker[3] = {1, 2, 3}; int testNum; cout << "Test Number? "; cin >> testNum; cout << endl; //Test Number 1: default constructor and to_string method if( testNum == 1 ) { cout << "Test #1: Testing default constructor and to_string():" << endl << endl; Vector alpha; Vector bravo = Vector(); cout << "alpha == " << alpha.to_string() << endl << "bravo == " << bravo.to_string() << endl; } //Test Number 2: alternate constructor and to_string method else if( testNum == 2 ) { cout << "Test #2: Testing alternate constructor and to_string:" << endl << endl; Vector charlie(slacker); //increment the values in slacker by 2 for (int i = 0; i < 3; i++) slacker[i] = i + 2; Vector delta = Vector(slacker); cout << "charlie == " << charlie.to_string() << endl << "delta == " << delta.to_string() << endl; } //Test Number 3: set method else if( testNum == 3 ) { cout << "Test #3: Testing set method:" << endl << endl; Vector echo; cout << "initially echo == " << echo.to_string() << endl << endl; echo.set(slacker); cout << "after call to set method echo == " << echo.to_string() << endl << endl; slacker[0] = -9; slacker[1] = 3; slacker[2] = 15; echo.set(slacker); cout << "after second call to set method echo == " << echo.to_string() << endl; } //Test Number 4: add methods else if( testNum == 4 ) { cout << "Test #4: Testing add methods:" << endl << endl; Vector foxtrot(slacker); int array[3] = {5, 14, -6}; //add with int [] argument Vector result = foxtrot.add(array); cout << "add with int [] argument: " << foxtrot.to_string() << " + <5, 14, -6> == " << result.to_string() << endl << endl; cout << "add with Vector argument: " << foxtrot.to_string() << " + " << result.to_string() << " == "; //add with Vector argument result = foxtrot.add(result); cout << result.to_string() << endl; } //Test Number 5: scalar multiplication method else if( testNum == 5 ) { cout << "Test #5: Testing scalar multiplication:" << endl << endl; slacker[0] = 14; slacker[1] = 2; slacker[2] = -9; Vector golf(slacker); Vector result = golf.multiply(5); cout << golf.to_string() << " * 5 == " << result.to_string() << endl << endl; result = golf.multiply(3); cout << golf.to_string() << " * 3 == " << result.to_string() << endl; } //Test Number 6: cross-product multiplication methods else if( testNum == 6 ) { cout << "Test #6: Testing cross-product multiplication methods:" << endl << endl; Vector hotel(slacker), india, result; slacker[0] = -4; slacker[1] = 3; slacker[2] = 5; //multiply with int [] argument result = hotel.multiply(slacker); cout << "multiply with int [] argument: " << hotel.to_string() << " X <-4, 3, 5> == " << result.to_string() << endl << endl; //change the values in hotel object slacker[0] = 4; slacker[1] = 13; slacker[2] = -5; hotel.set(slacker); //change the values in the india object slacker[0] = 2; slacker[1] = -3; slacker[2] = 6; india.set(slacker); //multiply with Vector argument result = india.multiply(hotel); cout << "multiply with Vector argument: " << india.to_string() << " X " << hotel.to_string() << " == " << result.to_string() << endl; } //Test Number 7: equality methods else if( testNum == 7 ) { cout << "Test #7: Testing isEqual methods" << endl << endl; Vector juliett(slacker), kilo(slacker); cout << "isEqual with int [] argument: comparing " << juliett.to_string() << " and <1, 2, 3>" << endl; //result should be equal if (juliett.isEqual(slacker)) cout << " equal -- SUCCESS" << endl; else cout << " equal -- FAILURE" << endl; //change the slacker array for (int i = 0; i < 3; i++) slacker[i] = (i * i); cout << endl << "isEqual with int [] argument: comparing " << juliett.to_string() << " and <0, 1, 4>" << endl; //result should be not equal if (juliett.isEqual(slacker)) cout << " not equal -- FAILURE" << endl; else cout << " not equal -- SUCCESS" << endl; cout << endl << endl << "isEqual with Vector argument: comparing " << juliett.to_string() << " and " << kilo.to_string() << endl; //result should be equal if (juliett.isEqual(kilo)) cout << " equal -- SUCCESS" << endl; else cout << " equal -- FAILURE" << endl; //change the slacker array and update the kilo Vecto for (int i = 0; i < 3; i++) slacker[i] = i * i + i; kilo.set(slacker); cout << endl << "isEqual with Vector argument: comparing " << juliett.to_string() << " and " << kilo.to_string() << endl; //result should be not equal if (juliett.isEqual(kilo)) cout << " not equal -- FAILURE" << endl; else cout << " not equal -- SUCCESS" << endl; } return 0; } //Code the constructors and methods for the Vector class below this line