👨‍💻 dev cpp port

development

fukurou

the supreme coder
ADMIN
.h
C++:
#ifndef ABSDICTIONARYDB_H
#define ABSDICTIONARYDB_H

#include <string>

class AbsDictionaryDB {
public:
    void save(const std::string& key, const std::string& value);
    std::string load(const std::string& key);
};

#endif // ABSDICTIONARYDB_H
.cpp:
C++:
#include "AbsDictionaryDB.h"

void AbsDictionaryDB::save(const std::string& key, const std::string& value) {
    // save to DB (override me)
}

std::string AbsDictionaryDB::load(const std::string& key) {
    // override me
    return "null";
}
 

fukurou

the supreme coder
ADMIN
Java:
public class Mutatable {
    public Boolean algKillSwitch = false;

    public String action(String ear, String skin, String eye) {
        return "";
    }

    public Boolean completed() {
        return true;
    }

    public String myName() {
        return this.getClass().getSimpleName();
    }
}
 

fukurou

the supreme coder
ADMIN
.h
C++:
class Mutatable {
public:
    bool algKillSwitch = false;

    string action(const string& ear, const string& skin, const string& eye);
    bool completed();
    string myName();
};

.cpp
C++:
string Mutatable::action(const string& ear, const string& skin, const string& eye) {
    return "";
}

bool Mutatable::completed() {
    return true;
}

string Mutatable::myName() {
    return "Mutatable";
}
 

fukurou

the supreme coder
ADMIN
.h
C++:
#ifndef APVERBATIM_H
#define APVERBATIM_H

#include "Mutatable.h"
#include <vector>
#include <string>

class APVerbatim : public Mutatable {
private:
    std::vector<std::string> sentences;
    int at = 0;

public:
    APVerbatim(const std::vector<std::string>& list1);
    APVerbatim(const std::string& sentence);

    std::string action(const std::string& ear, const std::string& skin, const std::string& eye) override;
    bool completed() override;
};

#endif // APVERBATIM_H

.cpp
C++:
#include "APVerbatim.h"

// Constructor taking a vector of strings
APVerbatim::APVerbatim(const std::vector<std::string>& list1) : sentences(list1) {
    if (sentences.empty()) {
        at = 30;
    }
}

// Constructor taking a single string as input
APVerbatim::APVerbatim(const std::string& sentence) {
    if (!sentence.empty()) {
        sentences.push_back(sentence);
    } else {
        at = 30;
    }
}

// Implementation of action
std::string APVerbatim::action(const std::string& ear, const std::string& skin, const std::string& eye) {
    std::string axnStr = "";
    if (at < sentences.size()) {
        axnStr = sentences[at];
        at++;
    }
    return axnStr;
}

// Implementation of completed
bool APVerbatim::completed() {
    return at >= sentences.size();
}
 
Top