Added first class to ex-rosalind-mockup which shows example classes for Rosalind problems

This commit is contained in:
Arkadiusz Hypki 2024-12-13 12:08:44 +01:00
parent 7af2902d49
commit fe6dd08ffd
4 changed files with 119 additions and 0 deletions

View File

@ -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 */

View File

@ -0,0 +1,32 @@
/*
* Seq.h
*
* Created on: Dec 13, 2024
* Author: ahypki
*/
#ifndef SEQ_H_
#define SEQ_H_
#include <string>
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_ */

View File

@ -0,0 +1,28 @@
//============================================================================
// Name : wmi-bioinf-rosalind-mockup.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#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;
}

View File

@ -7,6 +7,8 @@
//============================================================================
#include <iostream>
#include <string>
#include <unordered_map>
#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<string, string> 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<char, char> 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;
}