From fe6dd08ffdb5492e14244937932d5c5503fe57fe Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Fri, 13 Dec 2024 12:08:44 +0100 Subject: [PATCH] Added first class to ex-rosalind-mockup which shows example classes for Rosalind problems --- ex-rosalind-mockup/src/Seq.cpp | 39 +++++++++++++++++++ ex-rosalind-mockup/src/Seq.h | 32 +++++++++++++++ .../src/wmi-bioinf-rosalind-mockup.cpp | 28 +++++++++++++ ex5-library/src/main.cpp | 20 ++++++++++ 4 files changed, 119 insertions(+) create mode 100644 ex-rosalind-mockup/src/Seq.cpp create mode 100644 ex-rosalind-mockup/src/Seq.h create mode 100644 ex-rosalind-mockup/src/wmi-bioinf-rosalind-mockup.cpp diff --git a/ex-rosalind-mockup/src/Seq.cpp b/ex-rosalind-mockup/src/Seq.cpp new file mode 100644 index 0000000..e8b5660 --- /dev/null +++ b/ex-rosalind-mockup/src/Seq.cpp @@ -0,0 +1,39 @@ +/* + * Seq.cpp + * + * Created on: Dec 13, 2024 + * Author: ahypki + */ + +#include "Seq.h" + +namespace ahypkirosalind { + +Seq::Seq() { + // TODO Auto-generated constructor stub + +} + +Seq::~Seq() { + // TODO Auto-generated destructor stub +} + +string Seq::getSequence() { + return string(seq); +} + +Seq* Seq::setSequence(string newSeq) { + this->seq = newSeq; + return this; +} + +string Seq::getHeader() { + return string(header); +} + +Seq* Seq::setHeader(string newHeader) { + this->header = newHeader; + return this; +} + +} /* namespace ahypkirosalind */ diff --git a/ex-rosalind-mockup/src/Seq.h b/ex-rosalind-mockup/src/Seq.h new file mode 100644 index 0000000..ce9c51d --- /dev/null +++ b/ex-rosalind-mockup/src/Seq.h @@ -0,0 +1,32 @@ +/* + * Seq.h + * + * Created on: Dec 13, 2024 + * Author: ahypki + */ + +#ifndef SEQ_H_ +#define SEQ_H_ + +#include + +using namespace std; + +namespace ahypkirosalind { + +class Seq { +private: + string header; + string seq; +public: + Seq(); + virtual ~Seq(); + string getSequence(); + Seq* setSequence(string newSeq); + string getHeader(); + Seq* setHeader(string newHeader); +}; + +} /* namespace ahypkirosalind */ + +#endif /* SEQ_H_ */ diff --git a/ex-rosalind-mockup/src/wmi-bioinf-rosalind-mockup.cpp b/ex-rosalind-mockup/src/wmi-bioinf-rosalind-mockup.cpp new file mode 100644 index 0000000..e4c7be0 --- /dev/null +++ b/ex-rosalind-mockup/src/wmi-bioinf-rosalind-mockup.cpp @@ -0,0 +1,28 @@ +//============================================================================ +// Name : wmi-bioinf-rosalind-mockup.cpp +// Author : +// Version : +// Copyright : Your copyright notice +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include +#include "Seq.h" + +using namespace std; +using namespace ahypkirosalind; + +int main() { + cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! + + Seq* seq = Seq() + .setSequence("ACGGTA") + ->setHeader("> ape"); + cout << "Seq: " << seq->getSequence() << endl; // prints !!!Hello World!!! + + cout << "Or even: " << Seq() + .setSequence("GGCTC") + ->setHeader("> L'enfant terrible") << endl; // prints !!!Hello World!!! + + return 0; +} diff --git a/ex5-library/src/main.cpp b/ex5-library/src/main.cpp index 5559a99..468eb06 100644 --- a/ex5-library/src/main.cpp +++ b/ex5-library/src/main.cpp @@ -7,6 +7,8 @@ //============================================================================ #include +#include +#include #include "Human.h" #include "Employee.h" #include "Librarian.h" @@ -31,5 +33,23 @@ int main() { if (l.validate()) cout << "now it works, pesel of librarian" << l.getPesel(); + // zabawa a mapami o typie string + unordered_map keyValue; + keyValue["A"] = "Z"; + keyValue["S"] = "S"; + string s = "SAA"; + for (size_t i = 0; i < s.length(); ++i) { + cout << keyValue[s.substr(i, 1)]; + } + + // zabawa a mapami o typie char + unordered_map keyValue2; + keyValue2['A'] = 'Z'; + keyValue2['S'] = 'S'; + string s2 = "SAA"; + for (size_t i = 0; i < s2.length(); ++i) { + cout << keyValue2[s2[i]]; + } + return 0; }