implemented genus test results

This commit is contained in:
Michael Mandl 2018-06-15 17:53:43 +02:00
parent 060348fdc5
commit 5bc7edabc6
11 changed files with 129 additions and 61 deletions

View file

@ -0,0 +1,46 @@
#pragma once
#include "PRMap.h"
class GenusPR : public PRMap
{
public:
GenusPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
{ 7, 0 },
{ 8, 0 },
{ 9, 0 }
};
m_PRs = {
{ 1, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 0 },
{ 2, 1, 0, 0, 0 },
{ 3, 1, 1, 0, 0 },
{ 9, 1, 1, 0, 0 },
{ 13, 3, 2, 0, 0 },
{ 14, 5, 2, 1, 0 },
{ 19, 7, 2, 1, 0 },
{ 22, 8, 3, 1, 0 },
{ 27, 10, 4, 2, 0 },
{ 31, 13, 5, 2, 0 },
{ 35, 17, 7, 2, 0 },
{ 39, 18, 7, 2, 0 },
{ 46, 20, 8, 2, 0 },
{ 51, 23, 9, 2, 1 },
{ 56, 26, 11, 2, 1 },
{ 62, 34, 17, 4, 1 },
{ 71, 47, 22, 8, 4 },
{ 81, 57, 29, 17, 9 },
{ 94, 75, 49, 37, 27 },
{ 100, 100, 100, 100, 100 },
};
// clang-format on
}
};

View file

@ -0,0 +1,32 @@
#pragma once
#include "PRMap.h"
class PluralPR : public PRMap
{
public:
PluralPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 4, 6 },
{ 5, 6 },
{ 9, 0 }
};
m_PRs = {
{ 0, 0, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 1, 1, 0 },
{ 7, 2, 1 },
{ 10, 4, 1},
{ 26, 10, 2 },
{ 57, 25, 7 },
{ 79, 56, 27 },
{ 100, 100, 100 }
};
// clang-format on
}
};

View file

@ -1,5 +1,8 @@
#include "ResultModel.h"
#include "PluralPR.h"
#include "GenusPR.h"
#include <QDebug>
ResultModel::ResultModel(QObject *parent)
@ -114,7 +117,7 @@ void ResultModel::setAge(const Age &age)
emit dataChanged(index(1, 0), index(4, 8));
}
void ResultModel::setPluralResult(size_t points)
void ResultModel::setPluralResult(unsigned int points)
{
if (m_results[8].points() != points)
{
@ -124,3 +127,12 @@ void ResultModel::setPluralResult(size_t points)
}
}
void ResultModel::setGenusResult(unsigned int points)
{
if (m_results[4].points() != points)
{
m_results[4].setPoints(points);
m_results[4].setPR(GenusPR().lookup(m_age, points));
emit dataChanged(index(0, 4), index(4, 4));
}
}

View file

@ -1,38 +1,8 @@
#pragma once
#include "../Age.h"
#include "PRMap.h"
#include <QAbstractTableModel>
class PluralPR : public PRMap
{
public:
PluralPR()
{
// clang-format off
m_ages = {
{ 4, 0 },
{ 4, 6 },
{ 5, 6 },
{ 9, 0 }
};
m_PRs = {
{ 0, 0, 0 },
{ 0, 1, 0 },
{ 0, 1, 0 },
{ 1, 1, 0 },
{ 7, 2, 1 },
{ 10, 4, 1},
{ 26, 10, 2 },
{ 57, 25, 7 },
{ 79, 56, 27 },
{ 100, 100, 100 }
};
// clang-format on
}
};
class TestResult
{
private:
@ -93,5 +63,6 @@ public:
int role = Qt::DisplayRole) const override;
void setAge(const Age &age);
void setPluralResult(size_t points);
void setPluralResult(unsigned int points);
void setGenusResult(unsigned int points);
};