Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I ' m getting these 8 errors and I ' m not sure how to fix them: I ' m trying to create Create 1

I'm getting these 8 errors and I'm not sure how to fix them:
I'm trying to create Create 100 random Shapes and add them to the vector but Ican't with these errors.
Error C2661 'Line::Line': no overloaded function takes 2 arguments
Error C2661 'Rectangle::Rectangle': no overloaded function takes 3 arguments
Error C2661 'Triangle::Triangle': no overloaded function takes 3 arguments
Error C2661 'Circle::Circle': no overloaded function takes 2 arguments
Error C2661 'Line::Line': no overloaded function takes 2 arguments
Error C2661 'Rectangle::Rectangle': no overloaded function takes 3 arguments
Error C2661 'Triangle::Triangle': no overloaded function takes 3 arguments
Error C2661 'Circle::Circle': no overloaded function takes 2 arguments
class ShapeFactory {
public:
static Point2D RandomPoint(){
// Generate random x and y coordinates for the point
int x = rand()%100;
int y = rand()%100;
return Point2D(x, y);
}
static ConsoleColor RandomColor(){
// Generate a random color
int color = rand()%16;
return static_cast(color);
}
static std::unique_ptr RandomShape(){
// Generate a random number and create the corresponding shape
int shapeType = rand()%4;
switch (shapeType){
case 0:
return RandomLine();
case 1:
return RandomRectangle();
case 2:
return RandomTriangle();
case 3:
return RandomCircle();
default:
return nullptr;
}
}
static std::unique_ptr RandomLine(){
// Create a random line
Point2D start = RandomPoint();
Point2D end = RandomPoint();
return std::make_unique(start, end);
}
static std::unique_ptr RandomRectangle(){
// Create a random rectangle
Point2D topLeft = RandomPoint();
Point2D bottomRight = RandomPoint();
return std::make_unique(topLeft, bottomRight);
}
static std::unique_ptr RandomTriangle(){
// Create a random triangle
Point2D point1= RandomPoint();
Point2D point2= RandomPoint();
Point2D point3= RandomPoint();
return std::make_unique(point1, point2, point3);
}
static std::unique_ptr RandomCircle(){
// Create a random circle
Point2D center = RandomPoint();
int radius = rand()%50;
return std::make_unique(center, radius);
}
};
#include
#include
#include "ShapeFactory.h"
int main(){
int shapeType = rand()%16;
switch (shapeType){
case 6: {
std::vector> shapes;
for (int i =0; i <100; ++i){
shapes.push_back(ShapeFactory::RandomShape());
}
for (const auto& shape : shapes){
shape->draw();
}
break;
};
}

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

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago