Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
stress_ball.h #include #include #include #include using namespace std; enum class stress_ball_colors { red, blue, yellow, green }; enum class stress_ball_sizes { small, medium, large };
stress_ball.h
#include#include #include #include using namespace std; enum class stress_ball_colors { red, blue, yellow, green }; enum class stress_ball_sizes { small, medium, large }; class stress_ball { private: stress_ball_colors color; stress_ball_sizes size; public: stress_ball() : color(stress_ball_colors(rand() % 4)), size(stress_ball_sizes(rand() % 3)) {} stress_ball(stress_ball_colors c, stress_ball_sizes s) : color(c), size(s) {} stress_ball_colors get_color() const { return color; } stress_ball_sizes get_size() const { return size; } bool operator==(const stress_ball &c) { bool case1 = false; bool case2 = false; if (get_color() == c.get_color()) { case1 = true; } if (get_size() == c.get_size()) { case2 = true; } return case1 && case2; } void print_stress_ball() { switch (get_size()) { case stress_ball_sizes::small: cout
collection.h
#include#include #include #include #include "stress_ball.h" #include using namespace std; class Collection : public stress_ball{ private: stress_ball *array; int size; int capacity; void resize(){ capacity = 2 * capacity; if (capacity == 0){ capacity = 4; stress_ball *temp = new stress_ball[capacity]; for (int i = 0; i 2. (45 points) Add these functions for manipulating collections. They are not part of the class Collection. input operator (reading from a file): istream& operator (istream& is, Collection& c); reads from the istream is pairs in this format: color size (no parentheses or colons, use space to separate them). As colors use strings (you can use STL class string here): red, blue, yellow, green, and as sizes use strings: small, medium, large. You need to read from an input file where each pair is in one line. Use at least two input files: stress_balll.data and stress_ball2.data for two collections. output operator: ostream& operator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started