#pragma once #include #include #include enum class color { none, white, yellow, orange, red, blue, green, }; std::string to_string(color c); class abstract_cube; class abstract_face { public: abstract_face(const abstract_cube &); virtual std::string to_string() const = 0; private: const abstract_cube &_parent_cube; }; class cube1; class face1 final: public abstract_face { public: face1(const cube1 &parent, color); std::string to_string() const; private: const color _color; }; class cube3; class face3 final: public abstract_face { public: face3(const cube3 &parent); std::string to_string() const; private: std::array, 9> _faces; }; class abstract_cube { public: void flip_right(); void flip_left(); void flip_up(); void flip_down(); /* Return a new face. */ const std::shared_ptr front() const; const std::shared_ptr back() const; const std::shared_ptr left() const; const std::shared_ptr right() const; const std::shared_ptr up() const; const std::shared_ptr down() const; std::string to_string() const; protected: abstract_cube() = default; std::array, 6> _faces; }; class cube1 final: public abstract_cube { }; class cube3 final: public abstract_cube { public: cube3(color, color, color, color, color, color); cube3(const cube3 &) = default; cube3(cube3 &&) = default; /* Front face 90 deg clockwise. */ void f(); /* Front face 90 deg counter-clockwise. */ void F(); /* Back face 90 deg clockwise. */ void b(); /* Back face 90 deg counter-clockwise. */ void B(); /* Left face 90 deg clockwise. */ void l(); /* Left face 90 deg counter-clockwise. */ void L(); /* Right face 90 deg clockwise. */ void r(); /* Right face 90 deg counter-clockwise. */ void R(); /* Up face 90 deg clockwise. */ void u(); /* Up face 90 deg counter-clockwise. */ void U(); /* Down face 90 deg clockwise. */ void d(); /* Down face 90 deg counter-clockwise. */ void D(); /* * +---+---+---+ * | 0 | 1 | 2 | * +---+---+---+ * | 3 | 4 | 5 | * +---+---+---+ * | 6 | 7 | 8 | * +---+---+---+ */ };