CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <random>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
#include <array>
#include <initializer_list>
#include <variant>
using namespace std;
/*
“Create a class called ShapeFactory. Add 7 static methods: a method for creating a random point, a method for creating a random color, and methods for creating unique pointers for each Shape type (Shape, Line, Rectangle, Triangle, Circle). The methods that create the random Shapes should use make_unique and return a unique_ptr.”
*/
struct Point{
int x;
int y;
Point(int x, int y):x(x),y(y){}
};
struct Color{
int r;
int g;
int b;
Color(int r,int g,int b):r(r),g(g),b(b){}
};
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run