Skip to content

Commit 2b1a307

Browse files
committed
Module 3 - presentation + solutions
1 parent dfaa874 commit 2b1a307

File tree

6 files changed

+1021
-0
lines changed

6 files changed

+1021
-0
lines changed

module3/index.html

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6+
7+
<title>Object Oriented Programming - Coders School</title>
8+
9+
<meta name="description" content="OOP">
10+
<meta name="author" content="Mateusz Adamski & Łukasz Ziobroń">
11+
12+
<link rel="stylesheet" href="../../css/reset.css">
13+
<link rel="stylesheet" href="../../css/reveal.css">
14+
<link rel="stylesheet" href="../../css/theme/coders.css" id="theme">
15+
16+
<!-- Theme used for syntax highlighting of code -->
17+
<link rel="stylesheet" href="../../lib/css/monokai.css">
18+
19+
<!-- Printing and PDF exports -->
20+
<script>
21+
var link = document.createElement( 'link' );
22+
link.rel = 'stylesheet';
23+
link.type = 'text/css';
24+
link.href = window.location.search.match( /print-pdf/gi ) ? '../../css/print/pdf.css' : '../css/print/paper.css';
25+
document.getElementsByTagName( 'head' )[0].appendChild( link );
26+
</script>
27+
</head>
28+
<body>
29+
<div class="reveal">
30+
<div class="slides">
31+
<section>
32+
<section data-background="#111111">
33+
34+
<h1>OOP #3</h1>
35+
<h2>Object-Oriented Programming #3</h2>
36+
<a href="https://coders.school">
37+
<img width="500" data-src="../coders_school_logo.png" alt="Coders School" class="plain">
38+
</a>
39+
<h3>Mateusz Adamski</h3>
40+
<h3>Łukasz Ziobroń</h3>
41+
42+
</section>
43+
<section data-markdown>
44+
<textarea data-template>
45+
46+
## Agenda
47+
48+
1. <!-- .element: class="fragment fade-in-then-semi-out" --> dziedziczenie
49+
2. <!-- .element: class="fragment fade-in-then-semi-out" --> wielodziedziczenie
50+
3. <!-- .element: class="fragment fade-in-then-semi-out" --> funkcje wirtualne
51+
4. <!-- .element: class="fragment fade-in-then-semi-out" --> funkcje czysto wirtualne
52+
5. <!-- .element: class="fragment fade-in-then-semi-out" --> klasy abstrakcyjne
53+
6. <!-- .element: class="fragment fade-in-then-semi-out" --> interfejsy
54+
7. <!-- .element: class="fragment fade-in" --> przykładowe rozwiązania zadań z OOP#1
55+
7. <!-- .element: class="fragment fade-in" --> polimorfizm
56+
8. <!-- .element: class="fragment fade-in" --> pola i metody statyczne
57+
58+
</textarea>
59+
</section>
60+
<section data-markdown>
61+
<textarea data-template>
62+
63+
## Zadania
64+
65+
Repo GH `coders-school/object-oriented-programming`
66+
67+
[https://github.com/coders-school/object-oriented-programming/tree/master/module2](https://github.com/coders-school/object-oriented-programming/tree/master/module2)
68+
69+
</textarea>
70+
</section>
71+
<section data-markdown>
72+
<textarea data-template>
73+
74+
## Powtórka obiektowości
75+
76+
* <!-- .element: class="fragment fade-in" --> Co oznacza słowo <code>virtual</code>?
77+
* <!-- .element: class="fragment fade-in" --> Co oznacza słowo <code>override</code>?
78+
* <!-- .element: class="fragment fade-in" --> Co to jest dziedziczenie?
79+
* <!-- .element: class="fragment fade-in" --> Do czego służą operatory?
80+
* <!-- .element: class="fragment fade-in" --> Co to jest konstruktor?
81+
* <!-- .element: class="fragment fade-in" --> Czym jest klasa abstrakcyjna?
82+
83+
</textarea>
84+
</section>
85+
</section>
86+
<!--
87+
Note that Windows uses `\r\n` instead of `\n` as its linefeed character.
88+
For a regex that supports all operating systems, use `\r?\n` instead of `\n`.
89+
90+
Usage:
91+
Install dependencies
92+
93+
$ npm install
94+
Serve the presentation and monitor source files for changes
95+
96+
$ npm start
97+
Open http://localhost:8000 to view your presentation
98+
99+
You can change the port by using npm start -- --port=8001.
100+
-->
101+
<section data-markdown="presentation_solutions.md"
102+
data-separator-vertical="^___"
103+
data-separator-notes="^Note:">
104+
</section>
105+
<section data-markdown="presentation_polymorphism.md"
106+
data-separator-vertical="^___"
107+
data-separator-notes="^Note:">
108+
</section>
109+
<section data-markdown="presentation_static.md"
110+
data-separator-vertical="^___"
111+
data-separator-notes="^Note:">
112+
</section>
113+
<section data-markdown="presentation_homework.md"
114+
data-separator-vertical="^___"
115+
data-separator-notes="^Note:">
116+
</section>
117+
<section data-background="#111111">
118+
119+
<h1>Coders School</h1>
120+
<img width="400" data-src="../logo.png" alt="Coders School" class="plain">
121+
122+
</section>
123+
</div>
124+
</div>
125+
126+
<script src="../../js/reveal.js"></script>
127+
128+
<script>
129+
// More info about config & dependencies:
130+
// - https://github.com/hakimel/reveal.js#configuration
131+
// - https://github.com/hakimel/reveal.js#dependencies
132+
Reveal.initialize({
133+
width: 1200,
134+
height: 750,
135+
slideNumber: true,
136+
hash: true,
137+
pdfSeparateFragments: false,
138+
dependencies: [
139+
{ src: '../../plugin/externalcode/externalcode.js', condition: function() { return !!document.querySelector( '[data-code]' ); } },
140+
{ src: '../../plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
141+
{ src: '../../plugin/markdown/marked.js' },
142+
{ src: '../../plugin/markdown/markdown.js' },
143+
{ src: '../../plugin/notes/notes.js', async: true }
144+
]
145+
});
146+
</script>
147+
</body>
148+
</html>

module3/oop3.pdf

985 KB
Binary file not shown.

module3/presentation_homework.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<!-- .slide: data-background="#111111" -->
2+
3+
# Programowanie obiektowe
4+
5+
## Podsumowanie
6+
7+
<a href="https://coders.school">
8+
<img width="500" data-src="../coders_school_logo.png" alt="Coders School" class="plain">
9+
</a>
10+
11+
___
12+
13+
## Co pamiętasz z dzisiaj?
14+
15+
### Napisz na czacie jak najwięcej haseł
16+
<!-- .element: class="fragment fade-in" -->
17+
18+
1. <!-- .element: class="fragment fade-in" --> dziedziczenie
19+
2. <!-- .element: class="fragment fade-in" --> wielodziedziczenie
20+
3. <!-- .element: class="fragment fade-in" --> funkcje wirtualne
21+
4. <!-- .element: class="fragment fade-in" --> funkcje czysto wirtualne
22+
5. <!-- .element: class="fragment fade-in" --> klasy abstrakcyjne
23+
6. <!-- .element: class="fragment fade-in" --> interfejsy
24+
7. <!-- .element: class="fragment fade-in" --> polimorfizm
25+
8. <!-- .element: class="fragment fade-in" --> pola i metody statyczne
26+
27+
___
28+
29+
### Pre-work
30+
31+
* Dowiedzcie się czym jest problem diamentowy
32+
* Poczytajcie o zasadach SOLID, dotyczących pisania dobrego kodu obiektowego
33+
* Lektura o wzorcach projektowych z przykładami w C++ - [refactoring.guru](https://refactoring.guru/design-patterns)
34+
* Spróbujcie w grupie metodą Copy & Paste dorzucić system budowania cmake do projektu. W tym celu popatrzcie na dotychczasowe zadania domowe i plik CMakeLists.txt.
35+
36+
___
37+
38+
## Projekt grupowy
39+
40+
Wykorzystajcie kod napisany podczas zajęć. Możecie też skorzystać z kodu w katalogu [solutions](solutions)
41+
42+
Projekt grupowy - kontynuacja. Możecie zmienić grupę jeśli chcecie ;)
43+
44+
___
45+
46+
## Organizacja prac
47+
48+
* Jak wyglądało wasze daily?
49+
* Czy Code Review nie jest zaniedbane?
50+
* Czy współpraca idzie gładko?
51+
* Zróbcie sobie retrospektywę :)
52+
53+
___
54+
55+
### Punktacja
56+
57+
* 3 pierwsze zadania - 5 punktów
58+
* zadania 4, 5, 6 - 8 punktów
59+
* 20 punktów za dostarczenie wszystkich 6 zadań przed 05.07.2020 (niedziela) do 23:59
60+
* brak punktów bonusowych za dostarczenie tylko części zadań przed 05.07
61+
* 6 punktów za pracę w grupie dla każdej osoby z grupy.
62+
63+
___
64+
65+
## Zadanie 1
66+
67+
Napisz klasę `Store`, która będzie umożliwiała dokonywanie zakupów. Wykorzystaj poniższy enum i funkcje.
68+
69+
```cpp
70+
enum class Response {done, lack_of_money, lack_of_cargo, lack_of_space};
71+
72+
Response buy(Cargo* cargo, size_t amount, Player* player);
73+
Response sell(Cargo* cargo, size_t amount, Player* player);
74+
```
75+
76+
___
77+
78+
## Zadanie 2
79+
80+
W klasach `Alcohol`, `Fruit`, `Item` dopisz brakujące metody oraz ich implementacje.
81+
82+
```cpp
83+
// override from Cargo
84+
size_t getPrice() const override;
85+
std::string getName() const override { return name_; }
86+
size_t getAmount() const override { return amount_; }
87+
size_t getBasePrice() const override { return base_price_; }
88+
Cargo& operator+=(size_t amount) override;
89+
Cargo& operator-=(size_t amount) override;
90+
bool operator==(Cargo& cargo) const override;
91+
```
92+
93+
___
94+
95+
## Zadanie 3
96+
97+
Dopisz do klasy `Ship`, `Cargo` oraz `Stock` metodę `nextDay()`
98+
99+
* Klasa `Ship`: Metoda powinna odejmować po 1 sztuce monety za każdego członka załogi.
100+
* Klasa `Cargo`: Metoda powinna powodować psucie się towarów.
101+
* Klasa `Stock`: Metoda powinna zmieniać ilość towaru w sklepach.
102+
103+
___
104+
105+
## Zadanie 4 (dla ambitnych)
106+
107+
Spróbuj napisać klasę `Time`, która będzie odpowiadać za zarządzanie czasem w grze.
108+
109+
Klasa ta powinna informować inne klasy, takie jak `Cargo`, `Ship`, `Stock` o upłynięciu każdego dnia.
110+
111+
Poczytaj czym jest wzorzec projektowy [`Observer`](https://refactoring.guru/design-patterns/observer).
112+
113+
___
114+
115+
## Zadanie 5 (dla ambitnych)
116+
117+
Napisz zaprzyjaźniony operator wypisywania do strumienia
118+
119+
```cpp
120+
friend std::ostream& operator<<(std::ostream& out, const Store& store);
121+
```
122+
123+
Ma on w przystępny sposób wypisywać towar, jaki znajduje się w danym sklepie.
124+
125+
___
126+
127+
## Zadanie 6 (dla ambitnych)
128+
129+
Napisz klasę `Game`, która zarządzać będzie całą rozgrywką.
130+
131+
Dodaj jej jedną metodę publiczną `startGame()`.
132+
133+
Finalnie plik main powinien wyglądać tak:
134+
135+
```cpp
136+
#include "Game.hpp"
137+
138+
constexpr size_t start_money = 1'000;
139+
constexpr size_t game_days = 100;
140+
constexpr size_t final_goal = 2'000;
141+
142+
int main() {
143+
Game game(start_money, game_days, final_goal);
144+
game.startGame();
145+
146+
return 0;
147+
}
148+
```

0 commit comments

Comments
 (0)