solution

Fill in bubble.h and bubble.cc to create a Bubble class.

Your bubble will need to store private member variables to represent integer x and y coordinates, integer size (the radius), and a graphics::Color color.

Bubble needs to have public methods that access and mutate the x, y, color and size (8 methods total: a getter and a setter for each).

Finally, Bubble needs a method that returns a std::string representing the bubble. This method should output text with the format

Bubble at (x, y) with size s

main.cc :
First, in the first for loop, you will need to create a Bubble object from your Bubble class. Ensure you set the x, y and size based on what the user entered.

For the color, use the colors map to translate between what the user typed in and graphics::Color objects.

When you have created the Bubble object, add it to the bubbles vector.

Second, in the final for loop, you will need to get the Bubble object at the current index. Print it to the console using the std::string method you defined, and also draw it to the graphics::Image object image. You can use the DrawCircle method:

Here’s my code

bubble.h file

#ifndef BUBBLE_H
#define BUUBLE_H

class Bubble {
};

#endif
bubble.cc file

#include

#include “bubble.h”
class Bubble
{
private:
int x_;
int y_;
int radius;
int color;
public:
int GetX()
{
return x_;
}
void SetX(int x)
{
x_=x;
}
int GetY()
{
return y_;
}
void SetY(int y)
{
y_=y;
}
int GetColor()
{
return color;
}
void SetColor (int color_bubble)
{
color=color_bubble;
}
int GetRadius()
{
return radius;
}
void SetRadius (int radius_bubble)
{
radius=radius_bubble;
}
std::string show()
{
return “Bubble at (“+std::to_string(GetX())+”,”+std::to_string(GetY())+”) with size “+std::to_string(GetRadius());
}
};
main.cc file

#include

#include

#include “bubble.h”
#include “cpputils/graphics/image.h”

int main() {
// Get the number of bubbles from the user.
int num_bubbles;
std::cout << “How many bubbles do you want to draw? “;
std::cin >> num_bubbles;

const int kMaxChannel = 255;
const int kHalfChannel = 125;

// Create a map from strings to graphics::Color.
std::map

// Create a vector to store the bubbles.
std::vector

std::cout << “Tell me about your bubbles.n Valid x, y and size are between “
<< “0 and 500.n Valid colors are red, orange, yellow, green, “
<< “teal, blue, and purple.” << std::endl;

for (int i = 0; i < num_bubbles; i++) {
std::cout << “Bubble ” << i << std::endl;
std::string color;
std::cout << “What color? “;
std::cin >> color;

int size;
std::cout << “What size? “;
std::cin >> size;

int x;
std::cout << “What x? “;
std::cin >> x;

int y;
std::cout << “What y? “;
std::cin >> y;

//
// 1. Create a bubble and set the size, x and y from user input above.
// 2. Determine the graphics::Color from the colors map and set that too.
// 3. Add the bubble to the bubbles vector.
//

}

const int kImageSize = 500;
graphics::Image image(kImageSize, kImageSize);
for (int i = 0; i < num_bubbles; i++) {
//
// 1. Draw the Bubble at index i in the vector to the graphic::Image image.
// Use the Image::DrawCircle method.
// 2. Print the Bubble to the terminal using the ToString() method.
//
}

image.SaveImageBmp(“bubbles.bmp”);
std::cout << “Your bubbles were saved to bubbles.bmp” << std::endl;

return 0;

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp