Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My question is what code do I write for the for loop? Colorful bubbles Create a Bubble class that has accessors and mutators for an

My question is what code do I write for the for loop?

image text in transcribedimage text in transcribedimage text in transcribed

Colorful bubbles Create a Bubble class that has accessors and mutators for an x and y coordinate, color and size, and a ToString function that prints information about the Bubble object to the terminal. Complete main.cc to build and draw Bubble objects based on user input. Create the Bubble class 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 For example, for a bubble with size 30 at (42, 37), your function would return: Bubble at (42, 37) with size 30 You can use the std::to_string function to convert integers to strings, for example, std::to_string(2) gives "2". bubble.h will need to #include in order to define a function prototype using a std::string . You may name these functions however you want. Reference Functions review if you are wondering what to put in bubble.h and bubble.cc. Complete main.co main.cc already does most of the work to ask the user about bubble creation and to create and save an image as bubbles.bmp . You only need to fill in two parts: 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: * Draws a circle centered at (x, y) with radius Tradius), and color * color. Returns false if params are out of bounds. * bool DrawCircle(int x, int y, int radius, const Color& color); For example, image.DrawCircle(10, 20, 30, graphics::Color (42, 42, 42)); // Create a vector to store the bubbles. std::vector bubbles; std::cout > color; int size; std::cout > size; int x; std::cout > x; int y; std::cout > 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. } Colorful bubbles Create a Bubble class that has accessors and mutators for an x and y coordinate, color and size, and a ToString function that prints information about the Bubble object to the terminal. Complete main.cc to build and draw Bubble objects based on user input. Create the Bubble class 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 For example, for a bubble with size 30 at (42, 37), your function would return: Bubble at (42, 37) with size 30 You can use the std::to_string function to convert integers to strings, for example, std::to_string(2) gives "2". bubble.h will need to #include in order to define a function prototype using a std::string . You may name these functions however you want. Reference Functions review if you are wondering what to put in bubble.h and bubble.cc. Complete main.co main.cc already does most of the work to ask the user about bubble creation and to create and save an image as bubbles.bmp . You only need to fill in two parts: 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: * Draws a circle centered at (x, y) with radius Tradius), and color * color. Returns false if params are out of bounds. * bool DrawCircle(int x, int y, int radius, const Color& color); For example, image.DrawCircle(10, 20, 30, graphics::Color (42, 42, 42)); // Create a vector to store the bubbles. std::vector bubbles; std::cout > color; int size; std::cout > size; int x; std::cout > x; int y; std::cout > 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. }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago