79 lines
950 B
C++
79 lines
950 B
C++
#pragma once
|
|
#include "common.hpp"
|
|
|
|
class Shape // ÐÎ×´½Ó¿Ú
|
|
{
|
|
public:
|
|
virtual void draw() = 0;
|
|
|
|
};
|
|
|
|
class Rectangle :public Shape
|
|
{
|
|
public:
|
|
void draw();
|
|
};
|
|
|
|
class Square :public Shape
|
|
{
|
|
public:
|
|
void draw();
|
|
};
|
|
|
|
class Circle :public Shape
|
|
{
|
|
public:
|
|
void draw();
|
|
};
|
|
|
|
class Color // ÑÕÉ«½Ó¿Ú
|
|
{
|
|
public:
|
|
virtual void fill() = 0;
|
|
|
|
};
|
|
|
|
class Red :public Color
|
|
{
|
|
public:
|
|
void fill();
|
|
};
|
|
|
|
class Green :public Color
|
|
{
|
|
public:
|
|
void fill();
|
|
};
|
|
|
|
class Yellow :public Color
|
|
{
|
|
public:
|
|
void fill();
|
|
};
|
|
|
|
class AbstractFactory
|
|
{
|
|
public:
|
|
virtual Color* getColor(string color) = 0;
|
|
virtual Shape* getShape(string shape) = 0;
|
|
};
|
|
|
|
class ShapeFactory :public AbstractFactory
|
|
{
|
|
public:
|
|
Shape* getShape(string shape);
|
|
Color* getColor(string color);
|
|
};
|
|
|
|
class ColorFactory :public AbstractFactory
|
|
{
|
|
public:
|
|
Shape* getShape(string shape);
|
|
Color* getColor(string color);
|
|
};
|
|
|
|
class FactoryProducer
|
|
{
|
|
public:
|
|
AbstractFactory* getFactory(string choice);
|
|
}; |