item.cpp

来自「用data miming技术进行false prediction」· C++ 代码 · 共 50 行

CPP
50
字号
#include "Item.h"

Item::Item(string name) {
    this->mName = name;
    this->mCount = 1;
    this->mSeq = 0;
}

Item::Item(string name, int count, int seq) {
    this->mName = name;
    this->mCount = count;
    this->mSeq = seq;
}

string Item::getName() const {
    return mName;
}

int Item::getCount() const {
    return mCount;
}

int Item::getSeq() const {
    return mSeq;
}

void Item::incrementCount() {
    mCount++;
}

void Item::setCount(int i) {
    mCount = i;
}

bool Item::operator<(const Item& anotherItem) const {
    if (this->getCount() == anotherItem.getCount()) {
        return (this->getSeq() < anotherItem.getSeq());
    } else {
        return (this->getCount() < anotherItem.getCount());
    }
};

bool Item::operator>(const Item& anotherItem) const {
    if (this->getCount() == anotherItem.getCount()) {
        return (this->getSeq() > anotherItem.getSeq());
    } else {
        return (this->getCount() > anotherItem.getCount());
    }
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?