Skip to content

Commit

Permalink
Examples commited from previous year
Browse files Browse the repository at this point in the history
  • Loading branch information
akhtyamovpavel committed Feb 16, 2020
1 parent e8b28a7 commit 49f30b8
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Memento/cpp-source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ int main() {
game.StartNewGame();

game.IncreaseLevel();
std::cout << "Before first save" << std::endl;
game.ShowCurrentProgress();
caretaker.Save("first_save");

game.IncreaseLevel();
game.ShowCurrentProgress();

caretaker.Save("second_save");


Expand Down
3 changes: 2 additions & 1 deletion State/cpp-source/TrafficLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "states/State.h"

#include <memory>

using StatePointer = std::unique_ptr<State>;


Expand All @@ -25,7 +26,7 @@ class TrafficLight {
// TODO(akhtyamovpavel) Refactor this state
void PrintState();
private:
std::unique_ptr<State> state_;
StatePointer state_;
Direction direction_;
};

Expand Down
4 changes: 3 additions & 1 deletion State/cpp-source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "TrafficLight.h"
int main() {
TrafficLight light;
for (size_t state_switch = 0; state_switch < 10; ++state_switch) {
for (size_t state_switch = 0;
state_switch < 10;
++state_switch) {
light.PrintState();
light.ChangeColor();
}
Expand Down
2 changes: 1 addition & 1 deletion Visitor/cpp-source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(Visitor)
set(SOURCES main.cpp rooms/ElementRoom.cpp rooms/ElementRoom.h workers/Visitor.h workers/Visitor.cpp rooms/Kitchen.cpp rooms/Kitchen.h rooms/LivingRoom.cpp rooms/LivingRoom.h rooms/BathRoom.cpp rooms/BathRoom.h workers/Tiler.cpp workers/Tiler.h workers/Painter.cpp workers/Painter.h)
set(SOURCES main.cpp rooms/ElementRoom.cpp rooms/ElementRoom.h workers/Visitor.h workers/Visitor.cpp rooms/Kitchen.cpp rooms/Kitchen.h rooms/LivingRoom.cpp rooms/LivingRoom.h rooms/BathRoom.cpp rooms/BathRoom.h workers/Tiler.cpp workers/Tiler.h workers/Painter.cpp workers/Painter.h workers/Windower.cpp workers/Windower.h workers/SanTech.cpp workers/SanTech.h)

add_executable(${PROJECT_NAME} ${SOURCES} main.cpp)
8 changes: 8 additions & 0 deletions Visitor/cpp-source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
#include "rooms/LivingRoom.h"
#include "workers/Tiler.h"
#include "workers/Painter.h"
#include "workers/Windower.h"
#include "workers/SanTech.h"

int main() {
BathRoom bath_room;
Kitchen kitchen;
LivingRoom living_room;

SanTech sanTech;
kitchen.Accept(&sanTech);
kitchen.ShowDecorations();
Tiler tiler;

kitchen.Accept(&tiler);
Expand All @@ -28,4 +33,7 @@ int main() {
kitchen.ShowDecorations();
living_room.ShowDecorations();

Windower windower;
kitchen.Accept(&windower);
kitchen.ShowDecorations();
}
1 change: 1 addition & 0 deletions Visitor/cpp-source/rooms/Kitchen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
void Kitchen::Accept(Visitor *visitor) {
visitor->visit(this);
}

std::string Kitchen::GetName() {
return "Kitchen";
}
21 changes: 21 additions & 0 deletions Visitor/cpp-source/workers/SanTech.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Created by Pavel Akhtyamov on 2019-04-24.
//

#include "SanTech.h"
#include "../rooms/Kitchen.h"
#include "../rooms/LivingRoom.h"
#include "../rooms/BathRoom.h"


void SanTech::visit(Kitchen *kitchen) {
kitchen->wall.material = "sink";
}

void SanTech::visit(LivingRoom *living_room) {

}

void SanTech::visit(BathRoom *bath_room) {
bath_room->wall.material = "bath";
}
18 changes: 18 additions & 0 deletions Visitor/cpp-source/workers/SanTech.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Created by Pavel Akhtyamov on 2019-04-24.
//

#pragma once

#include "Visitor.h"

class SanTech : public Visitor {
public:
void visit(Kitchen *kitchen) override;
void visit(LivingRoom *living_room) override;
void visit(BathRoom *bath_room) override;

};



22 changes: 22 additions & 0 deletions Visitor/cpp-source/workers/Windower.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Created by Pavel Akhtyamov on 2019-04-23.
//

#include "Windower.h"
#include "../rooms/Kitchen.h"
#include "../rooms/BathRoom.h"
#include "../rooms/LivingRoom.h"


void Windower::visit(Kitchen *kitchen) {
kitchen->wall.material = "window";
}

void Windower::visit(LivingRoom *living_room) {
living_room->wall.material = "window";
living_room->wall.color = "black";
}

void Windower::visit(BathRoom *bath_room) {

}
17 changes: 17 additions & 0 deletions Visitor/cpp-source/workers/Windower.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Created by Pavel Akhtyamov on 2019-04-23.
//

#pragma once

#include "Visitor.h"
class Windower : public Visitor {
public:
void visit(Kitchen *kitchen) override;
void visit(LivingRoom *living_room) override;
void visit(BathRoom *bath_room) override;

};



0 comments on commit 49f30b8

Please sign in to comment.