Question: stress_ball.h 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.h
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==(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
Question


1. (35 points) The class Collection defines a collection as an array that can be automatically resized as neces- sary using dynamically allocated arrays. You are not allowed to use the STL class vector. (a) Write a C++ class Collection which uses the class Stress_ball. The collection holds stress balls of different colors and sizes (see Part 1) and can contain many stress balls of the same color and size. The class Collection should have three private members: Stress_ball marray; //pointer to dynamically allocated memory int size; //logical size of array - the number of elements in use int capacity; //physical size of array Note that size Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
