-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
219 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
all: | ||
g++ *.cpp -o lab3 | ||
./lab3 | ||
./lab3 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
#Lab 3 - Kontenery | ||
#Lab 3 - Kontenery | ||
|
||
##Czym są adaptery? | ||
Adapter jest jednym z wzorców projektowych. Zadaniem adaptera jest przekształcanie interfejsów różnych klas w taki, który jest oczekiwany przez użytkownika. Innymi słowy adapter daje nam metody, za pomocą których możemy np. pobierać i zapisywać dane w określony sposób, ale sposób organizacji danych w adapterze jest nieznany. Dzięki adapterowi możemy zmienić klasę zarządzającą danymi nie zmieniając działania całej aplikacji. | ||
|
||
### Tablica | ||
|
||
### Stos | ||
|
||
### Kolejka | ||
|
||
### Słownik | ||
|
||
### Zbiór | ||
|
||
## Zadanie na 5 | ||
Uzupełnij klasę `Slav` o metodę rozpoznającą płeć Słowianina/Słowianki, zwracając ją jako `enum`. Stwórz słownik (`map`) zwracający tablicę (`vector`) wskaźników na wszystkich mężczyzn, gdy podamy mu klucz odpowiadający mężczyźnie i tablicę wszystkich kobiet, gdy podamy mu klucz odpowiadający kobiecie. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "Slav.h" | ||
#include <fstream> | ||
|
||
using namespace std; | ||
|
||
vector <string> Slav::names; | ||
|
||
void Slav::init() | ||
{ | ||
srand(time(NULL)); | ||
ifstream file("names.dat"); | ||
copy(istream_iterator<string>(file), | ||
istream_iterator<string>(), | ||
back_inserter(names)); | ||
file.close(); | ||
} | ||
|
||
Slav::Slav() | ||
{ | ||
static int ret = (init(), 1); // Leniwa inicjalizacja | ||
_name = names[rand() % names.size()]; | ||
} | ||
|
||
string Slav::name() | ||
{ | ||
return _name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
class Slav | ||
{ | ||
private: | ||
static void init(); | ||
static std::vector <string> names; | ||
string _name; | ||
public: | ||
Slav(); | ||
string name(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
// Kontenery sekwencyjne | ||
#include <vector> // Łańcuch | ||
// Kontenery | ||
#include <vector> // Tablica | ||
#include <set> // Zbiór | ||
#include <map> // Słownik | ||
|
||
// Adaptery | ||
#include <stack> // Stos | ||
#include <queue> // Kolejka | ||
// Kontenery asocjujące | ||
#include <map> // Słownik | ||
#include <set> // Zbiór | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "Slav.h" | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
/* code */ | ||
return 0; | ||
int n = atoi(argv[1]); | ||
Slav *slavs = new Slav[n]; | ||
for (int i = 0; i < n; ++i) | ||
printf("[%i] %s\n", i, slavs[i].name().c_str()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
Barnim | ||
Bądzsław | ||
Bąsław | ||
Bdzigost | ||
Bedgost | ||
Będzieciech | ||
Będzimir | ||
Będziemir | ||
Będziemirz | ||
Będomir | ||
Będzimysł | ||
Biecsław | ||
Biecław | ||
Biezdar | ||
Biezdziad | ||
Biezpraw | ||
Brzezpraw | ||
Biezprzem | ||
Biezprzym | ||
Bezprym | ||
Biezstryj | ||
Biestryj | ||
Biezstryk | ||
Brzezstryk | ||
Brzestryk | ||
Biezuj | ||
Biezwuj | ||
Biezrząd | ||
Blizbor | ||
Blizborz | ||
Bodzepor | ||
Bogdał | ||
Bogdaj | ||
Bogodał | ||
Bogdasz | ||
Bogudan | ||
Bogodan | ||
Bogdan | ||
Bohdan | ||
Bodan | ||
Bogodar | ||
Bogudar | ||
Boguchwał | ||
Boguchał | ||
Bogufał | ||
Bogofał | ||
Bogfał | ||
Bogchwał | ||
Bochwał | ||
Bofał | ||
Bogumił | ||
Bogomił | ||
Bogmił | ||
Bogomieł | ||
Bogumieł | ||
Bogmieł | ||
Bogumysław | ||
Bogurad | ||
Bogured | ||
Bogusąd | ||
Bogusław | ||
Bogosław | ||
Bohusław | ||
Bogsław | ||
Bogwiedz | ||
Bogwidza | ||
Bogowid | ||
Bolebor | ||
Boleczaj | ||
Boleczest | ||
Bolelut | ||
Bolemir | ||
Bolemysł | ||
Bolesław | ||
Bosław | ||
Borzuj | ||
Borzywuj | ||
Borzygniew | ||
Borzgniew | ||
Borzymir | ||
Borzysław | ||
Borzywoj | ||
Borzuj | ||
Bożebor | ||
Bożeciech | ||
Bożciech | ||
Bożydar | ||
Bożdar | ||
Bożysław | ||
Bracsław | ||
Bratomir | ||
Bratumił | ||
Bratomił | ||
Bratmił | ||
Bretomił | ||
Bretmił | ||
Braturad | ||
Brodzisław | ||
Brocsław | ||
Barcsław | ||
Barcław | ||
Bronimir | ||
Bromir | ||
Bronisąd | ||
Bronisław | ||
Brosław | ||
Brzezdob | ||
Brzezdoma | ||
Budziboj | ||
Budzigniew | ||
Budzimir | ||
Budzisław | ||
Budzsław | ||
Budziwoj | ||
Budźwoj | ||
Budziwuj | ||
Bygost | ||
Bytomir | ||
Bądzsława | ||
Biedziesława | ||
Biecsława | ||
Biecława | ||
Biezdziadka | ||
Bogdała | ||
Bogdana | ||
Bogna | ||
Boguchwała | ||
Bogufała | ||
Bogudać | ||
Bogudarz | ||
Bogodarz | ||
Bogumiła | ||
Bogmiła | ||
Bogusława | ||
Boguwłość | ||
Bogowłość | ||
Boguwola | ||
Bohuwola | ||
Bolemira | ||
Bolesława | ||
Bosława | ||
Bożeciecha | ||
Bożena | ||
Bratumiła | ||
Bratomiła | ||
Bratmiła | ||
Bronisława | ||
Budzisława |