Make sure your Assignment 1's class* contains at least one (1) numeric attribute (int, float, double)....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Make sure your Assignment 1's class* contains at least one (1) numeric attribute (int, float, double). If it does not, add a numeric attribute to your class. Define the behavior of the following operators in your class' objects: • Two objects of that class are considered equal (==) if ... ⚫ The sum (+) of two objects of that class returns.... ⚫ When passing one object of that class to cout operator, it displays... Using those definitions, modify your class to overload those operators. In the corresponding operator overloading function add a comment that explains the operator functionality (i.e. the definition of each operators). * If you received feedback related to your Assignment 1's class, update it appropriately before using it in this assignment. In the main program Create three objects of your Assignments 1's class and demonstrate that ==, +, and cout operators works as expected when using them with your class' objects. Submission Files to submit: • Visual Studio solution/project files. • Class files (.h and .cpp) . Main program (.cpp) Submit the Visual Studio project in a zip folder. Example of expected submission Note: The Solution/project files are not presented in these examples since those are automatically generated by Visual Studio. However, those are expected in students' submission. GroupCohesiveness.h #include <iostream> class GroupCohesiveness { private: int answer, answer1, answer2, answer3; public: Submit the Visual Studio project in a zip folder. Example of expected submission Note: The Solution/project files are not presented in these examples since those are automatically generated by Visual Studio. However, those are expected in students' submission. GroupCohesiveness.h #include <iostream> class GroupCohesiveness { private: int answere, answer1, answer2, answer3; public: }; void setAnswer(int a); void setAnswer1(int a); void setAnswer 2(int a); void setAnswer3(int a); int getAnswer@() const; int getAnswer1() const; int getAnswer2() const; int getAnswer3() const; float getGroupCohesiveness() const; bool operator= (const GroupCohesiveness& survey2) const; GroupCohesiveness operator (const GroupCohesiveness& survey2) const; friend ostreams operator<<(ostream& os, const GroupCohesiveness& survey); GroupCohesiveness(); GroupCohesiveness (int a0, int al, int a2, int a3); -GroupCohesiveness(); GroupCohesiveness.cpp #include "GroupCohesivness.h" void GroupCohesivness::setAnswer(int a) { if (a>=1 && a<5) answer-a; void GroupCohesivness::setAnswer1(int a) { if (a>-1 && a<=5) answer1-a; void GroupCohesivness::setAnswer2(int a) { if (a>-1 && a<-5) answer2-a; void GroupCohesivness::setAnswer3(int a) { if (a>-1 && a<-5) answer3-a; int GroupCohesivness::getAnswer() const { } return answer0; int GroupCohesivness::getAnswer1() const { } return answer1; int GroupCohesivness::getAnswer2() const { } return answer2; int GroupCohesivness::getAnswer3() const { return answer3; float GroupCohesivness::getGroupCohesiveness() const { return (answer8+answer1+answer2+answer3)/4.0; // Two objects of that class are considered equal (--) if all the answers are the same bool GroupCohesivness::operator==(const GroupCohesiveness& survey2) const { return answer--survey2.answer && answer1--survey2.answer1 && answer 2-survey2.answer2 && answer3--survey2.answer3; // The sum (+) of two objects of that class returns a new object whose answers are the average of the 2 operand's GroupCohe siveness answers. GroupCohesiveness GroupCohesivness::operator+(const GroupCohesiveness& survey2) const { GroupCohesiveness temp; temp.answer0-(answer+survey2.answer0)/2; temp.answer1=(answer1+survey2.answer1)/2; temp.answer 2-(answer2+survey2.answer2)/2; temp.answer 3-(answer3+survey2.answer3)/2; return temp; } GroupCohesiveness temp; temp.answer0=(answer0+survey2.answer0)/2; temp.answer1=(answer1+survey2.answer1)/2; temp.answer2=(answer 2+survey2.answer 2)/2; temp.answer3=(answer3+survey2.answer3)/2; return temp; } // When passing one object of that class to cout operator, it displays the answers of the surveys enclosed by parentheses. friend ostream& operator<<(ostream& os, const GroupCohesiveness& survey) { os << "("<< survey.answer << "," << survey.answer1 << "," << survey.answer2 << "," << survey.answer3 << ")"; return os; GroupCohesiveness::GroupCohesiveness() { } answer0=1; answer1=1; answer2=1; answer3=1; GroupCohesiveness::GroupCohesiveness (int a0, int al, int a2, int a3) { answer0=a0; answer1=a1; answer2=a2; } answer3=a3; GroupCohesiveness::~GroupCohesiveness() { } cout << "A Group Cohesiveness object has been removed from memory."; Main.cpp main() { GroupCohesiveness surveyA(1,2,3,2); GroupCohesiveness surveyB (3,5,4,3); GroupCohesiveness surveyC; surveyC=surveyA; if (surveyA==surveyB) cout << "Survey A and Survey B are equal" << endl; else cout << "Survey A and Survey B are not equal" << endl; if (surveyA==surveyC) cout << "Survey A and Survey C are equal" << endl; else cout << "Survey A and Survey C are not equal" << endl; cout << "The average of Survey A and Survey B is: "; GroupCohesiveness temp; temp = surveyA+surveyB; cout << temp << endl; } Assignment 4 Project format Criteria Ratings Pts 2 pts A Visual studio project was submitted Compilation The project executes without a compilation error Header definition Class members including operator overloading are defined correctly. 2 pts 5 pts Source implementation 5 pts Function members including operator overloading are implemented correctly. Operator overloading definition in source 3 pts Each operator overloading definition includes a comment that explains the behavior of the corresponding operator. Main program 3 pts The main program demonstrates the use of the overloaded operators ==, +, and cout correctly. Total Points: 20 main.cpp + x assignment01.h Miscellaneous Files - No Configurations 1 2 Assignment01.cpp #include <iostream> #include "assignment01.h" using namespace std; RacingCar* car = new RacingCar(); int speed, year, MPG, price; cout<<"Enter speed: "; cin >> speed; car->setspeed (speed); 3 4 5 Bint main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 24 25 26 27 28 29 30 33 1222222222223 cout << "Enter year: "; cin >> year; car->setyear(year); cout << "Enter MPG: "; cin >> MPG; car->setMPG(MPG); cout << "Enter price: "; cin >> price; car->setprice(price); cout << "Speed: " << car->getspeed() << endl; cout << "Year: " << car->getyear() << endl; cout << "MPG: " << car->getMPG() << endl; cout << "Price: " << car->getprice() << endl; (Global Scope) cout << "Racing car value: " << car->getRacingCar() << endl; delete car; return 0; 100% No issues found Output Show output from: main.cpp assignment01.h× Assignment01.cpp Miscellaneous Files - No Configurations 1 #include <iostream> 123 using namespace std; Eclass Racing Car { private: int speed, year, MPG, price; public: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [}; void setspeed(int a); void setyear(int b); void setMPG(int c); void setprice (int d); int getspeed() const; int getyear() const; int getMPG() const; int getprice() const; float getRacing Car() const; RacingCar(); Racing Car(int speed, int year, int MPG, int price); ~RacingCar(); Miscellaneous Files - No Configurations #include "assignment01.h" 2 using namespace std; 123456789 10 11 12 13 14 15 16 17 18 Evoid RacingCar::setspeed (int a) { if (a >= 60 && a <= 200) speed = a; Evoid RacingCar::setyear(int b) { if (b>= 2000 && b <= 2023) year = b; Evoid RacingCar::setMPG(int c) { if (c >= 20 && c <= 40) MPG = c; Evoid RacingCar::setprice (int d) { if (d >= 50000 && d <= 100000) price = d; Fint RacingCar::getspeed () const { return speed; } 19 20 Bint RacingCar::getyear() const { return year; Bint RacingCar::getMPG() const { return MPG; sint RacingCar::getprice() const { return price; float RacingCar::getRacing Car() const { return (speed&&year&&MPG&&price); RacingCar:: RacingCar() { 21 22 23 24 25 26 27 } 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 speed = 90; year = 2021; MPG = 20; price = 88888; RacingCar:: Racing Car(int a, int b, int c, int d) { speed = a; year = b; MPG Ci price = d; RacingCar::~Racing Car() { cout << "Racing Cars object has been removed from memory."; Make sure your Assignment 1's class* contains at least one (1) numeric attribute (int, float, double). If it does not, add a numeric attribute to your class. Define the behavior of the following operators in your class' objects: • Two objects of that class are considered equal (==) if ... ⚫ The sum (+) of two objects of that class returns.... ⚫ When passing one object of that class to cout operator, it displays... Using those definitions, modify your class to overload those operators. In the corresponding operator overloading function add a comment that explains the operator functionality (i.e. the definition of each operators). * If you received feedback related to your Assignment 1's class, update it appropriately before using it in this assignment. In the main program Create three objects of your Assignments 1's class and demonstrate that ==, +, and cout operators works as expected when using them with your class' objects. Submission Files to submit: • Visual Studio solution/project files. • Class files (.h and .cpp) . Main program (.cpp) Submit the Visual Studio project in a zip folder. Example of expected submission Note: The Solution/project files are not presented in these examples since those are automatically generated by Visual Studio. However, those are expected in students' submission. GroupCohesiveness.h #include <iostream> class GroupCohesiveness { private: int answer, answer1, answer2, answer3; public: Submit the Visual Studio project in a zip folder. Example of expected submission Note: The Solution/project files are not presented in these examples since those are automatically generated by Visual Studio. However, those are expected in students' submission. GroupCohesiveness.h #include <iostream> class GroupCohesiveness { private: int answere, answer1, answer2, answer3; public: }; void setAnswer(int a); void setAnswer1(int a); void setAnswer 2(int a); void setAnswer3(int a); int getAnswer@() const; int getAnswer1() const; int getAnswer2() const; int getAnswer3() const; float getGroupCohesiveness() const; bool operator= (const GroupCohesiveness& survey2) const; GroupCohesiveness operator (const GroupCohesiveness& survey2) const; friend ostreams operator<<(ostream& os, const GroupCohesiveness& survey); GroupCohesiveness(); GroupCohesiveness (int a0, int al, int a2, int a3); -GroupCohesiveness(); GroupCohesiveness.cpp #include "GroupCohesivness.h" void GroupCohesivness::setAnswer(int a) { if (a>=1 && a<5) answer-a; void GroupCohesivness::setAnswer1(int a) { if (a>-1 && a<=5) answer1-a; void GroupCohesivness::setAnswer2(int a) { if (a>-1 && a<-5) answer2-a; void GroupCohesivness::setAnswer3(int a) { if (a>-1 && a<-5) answer3-a; int GroupCohesivness::getAnswer() const { } return answer0; int GroupCohesivness::getAnswer1() const { } return answer1; int GroupCohesivness::getAnswer2() const { } return answer2; int GroupCohesivness::getAnswer3() const { return answer3; float GroupCohesivness::getGroupCohesiveness() const { return (answer8+answer1+answer2+answer3)/4.0; // Two objects of that class are considered equal (--) if all the answers are the same bool GroupCohesivness::operator==(const GroupCohesiveness& survey2) const { return answer--survey2.answer && answer1--survey2.answer1 && answer 2-survey2.answer2 && answer3--survey2.answer3; // The sum (+) of two objects of that class returns a new object whose answers are the average of the 2 operand's GroupCohe siveness answers. GroupCohesiveness GroupCohesivness::operator+(const GroupCohesiveness& survey2) const { GroupCohesiveness temp; temp.answer0-(answer+survey2.answer0)/2; temp.answer1=(answer1+survey2.answer1)/2; temp.answer 2-(answer2+survey2.answer2)/2; temp.answer 3-(answer3+survey2.answer3)/2; return temp; } GroupCohesiveness temp; temp.answer0=(answer0+survey2.answer0)/2; temp.answer1=(answer1+survey2.answer1)/2; temp.answer2=(answer 2+survey2.answer 2)/2; temp.answer3=(answer3+survey2.answer3)/2; return temp; } // When passing one object of that class to cout operator, it displays the answers of the surveys enclosed by parentheses. friend ostream& operator<<(ostream& os, const GroupCohesiveness& survey) { os << "("<< survey.answer << "," << survey.answer1 << "," << survey.answer2 << "," << survey.answer3 << ")"; return os; GroupCohesiveness::GroupCohesiveness() { } answer0=1; answer1=1; answer2=1; answer3=1; GroupCohesiveness::GroupCohesiveness (int a0, int al, int a2, int a3) { answer0=a0; answer1=a1; answer2=a2; } answer3=a3; GroupCohesiveness::~GroupCohesiveness() { } cout << "A Group Cohesiveness object has been removed from memory."; Main.cpp main() { GroupCohesiveness surveyA(1,2,3,2); GroupCohesiveness surveyB (3,5,4,3); GroupCohesiveness surveyC; surveyC=surveyA; if (surveyA==surveyB) cout << "Survey A and Survey B are equal" << endl; else cout << "Survey A and Survey B are not equal" << endl; if (surveyA==surveyC) cout << "Survey A and Survey C are equal" << endl; else cout << "Survey A and Survey C are not equal" << endl; cout << "The average of Survey A and Survey B is: "; GroupCohesiveness temp; temp = surveyA+surveyB; cout << temp << endl; } Assignment 4 Project format Criteria Ratings Pts 2 pts A Visual studio project was submitted Compilation The project executes without a compilation error Header definition Class members including operator overloading are defined correctly. 2 pts 5 pts Source implementation 5 pts Function members including operator overloading are implemented correctly. Operator overloading definition in source 3 pts Each operator overloading definition includes a comment that explains the behavior of the corresponding operator. Main program 3 pts The main program demonstrates the use of the overloaded operators ==, +, and cout correctly. Total Points: 20 main.cpp + x assignment01.h Miscellaneous Files - No Configurations 1 2 Assignment01.cpp #include <iostream> #include "assignment01.h" using namespace std; RacingCar* car = new RacingCar(); int speed, year, MPG, price; cout<<"Enter speed: "; cin >> speed; car->setspeed (speed); 3 4 5 Bint main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 24 25 26 27 28 29 30 33 1222222222223 cout << "Enter year: "; cin >> year; car->setyear(year); cout << "Enter MPG: "; cin >> MPG; car->setMPG(MPG); cout << "Enter price: "; cin >> price; car->setprice(price); cout << "Speed: " << car->getspeed() << endl; cout << "Year: " << car->getyear() << endl; cout << "MPG: " << car->getMPG() << endl; cout << "Price: " << car->getprice() << endl; (Global Scope) cout << "Racing car value: " << car->getRacingCar() << endl; delete car; return 0; 100% No issues found Output Show output from: main.cpp assignment01.h× Assignment01.cpp Miscellaneous Files - No Configurations 1 #include <iostream> 123 using namespace std; Eclass Racing Car { private: int speed, year, MPG, price; public: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [}; void setspeed(int a); void setyear(int b); void setMPG(int c); void setprice (int d); int getspeed() const; int getyear() const; int getMPG() const; int getprice() const; float getRacing Car() const; RacingCar(); Racing Car(int speed, int year, int MPG, int price); ~RacingCar(); Miscellaneous Files - No Configurations #include "assignment01.h" 2 using namespace std; 123456789 10 11 12 13 14 15 16 17 18 Evoid RacingCar::setspeed (int a) { if (a >= 60 && a <= 200) speed = a; Evoid RacingCar::setyear(int b) { if (b>= 2000 && b <= 2023) year = b; Evoid RacingCar::setMPG(int c) { if (c >= 20 && c <= 40) MPG = c; Evoid RacingCar::setprice (int d) { if (d >= 50000 && d <= 100000) price = d; Fint RacingCar::getspeed () const { return speed; } 19 20 Bint RacingCar::getyear() const { return year; Bint RacingCar::getMPG() const { return MPG; sint RacingCar::getprice() const { return price; float RacingCar::getRacing Car() const { return (speed&&year&&MPG&&price); RacingCar:: RacingCar() { 21 22 23 24 25 26 27 } 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 speed = 90; year = 2021; MPG = 20; price = 88888; RacingCar:: Racing Car(int a, int b, int c, int d) { speed = a; year = b; MPG Ci price = d; RacingCar::~Racing Car() { cout << "Racing Cars object has been removed from memory.";
Expert Answer:
Related Book For
Managerial Accounting
ISBN: 978-0078025518
2nd edition
Authors: Stacey Whitecotton, Robert Libby, Fred Phillips
Posted Date:
Students also viewed these accounting questions
-
Using the opening and closing basis approach to finish the following blanks. Date Cash Futures 1-Oct Cash Price $6.30 May Futures $6.75 Cost of holding from Oct 1 to May 1 = $0.21 Expected Closing...
-
Determine the equation of the quadratic regression function for the data. x: 1 2 3 4 5 y: 100.8 101.3 101.5 100.9 99.8
-
(Payback period, net present value, profitability index, and internal rate of return calculations) You are considering a project with an initial cash outlay of $72,000 and expected cash flows of...
-
Returning to the data set canadaemplmntdata from Problem 17.4, get a line chart of Accommodation jobs by subsetting by VECTOR = v81682. Problem 17.4 The file canadaemplmntdata contains quarterly...
-
Describe the guidelines for selecting an appropriate bivariate statistic. That is, what do you need to ask about the nature of the data and the research design in order to choose an appropriate...
-
Review the information on non-profit educational institutions that you collected during Week 4. To the extent possible, determine how each institution defines "operating income." Evaluate the issues...
-
On 1 April 2001, Machinery Limited bought 80% of the ordinary share capital of Components Limited. On 1 April 2003, Machinery Limited was itself taken over by Sales Limited who purchased 75% of the...
-
Maness Industries plans to issue some $100 par preferred stock with an 11 percent dividend. The stock is selling on the market for $97.00, and Maness must pay flotation costs of 5 percent of the...
-
A survey seeks to find if adults in Minnesota feel women have better job opportunities than they did 20 years ago. Which survey is likely to produce the best results? a) An online survey that is...
-
Jayla is a human resource manager for a glass manufacturer. She is in the process of deciding how many new employees her company will need in order to fill vacant positions in the near future. In...
-
Project Description You are to modify your project 2 to incorporate GUI components of TextField, TextArea and Button with the following requirements. Write an application that calculates the...
-
14. Stroma is a component of a. mitochondria. b. chloroplasts. c. lysosomes. d. peroxisomes. 15. Which of the following organisms produces toxins that target cholesterol? a. Aeromonas hydrophila b....
-
There are 18 males and 20 females in a school marching band. Find the following ratios. a) female band members to total band members b) male band members to female band members female members to...
-
A poorly insulated counter-flow double-tube heat exchanger is used to cool ethylene glycol (cp = 2.56 kJ/(kg.K) flowing at a rate of 2 kg/s from 80 to 40 C using water (cp= 4.18 kJ/(kg.K)) that...
-
2. A second tract of land (site number 622) with a building was acquired for $300,000. The closing statement indicated that the land value was $200,000 and the building value was $100,000. Shortly...
-
Sweet Corporation made credit sales of $15,600 which are subject to 6% sales tax. The corporation also made cash sales which totaled $12,402 including the 6% sales tax. (a) Your answer is partially...
-
President Lee Coone has asked you to continue planning for an integrated corporate NDAS network. Ultimately, this network will link all the offices with the Tampa head office and become the...
-
The statements of financial position for Maxi Ltd and Mini Ltd are set out below. On 1 April last year, Maxi Ltd bought 1,500,000 shares of Mini Ltd for a total consideration of 5 million. At that...
-
A year ago Pod Ltd bought 225,000 1 fully paid ordinary shares of Pea Ltd for a consideration of 500,000. Pea Ltds share capital and share premium were each the same as at todays date. Simplified...
-
It has been suggested that too much information might be as bad as too little information for users of annual reports. Explain.
Study smarter with the SolutionInn App