From c9499bd0a5d554c0b118897825d52c593a5111a6 Mon Sep 17 00:00:00 2001 From: hama Date: Thu, 11 Feb 2016 23:44:46 +0100 Subject: [PATCH] recommand: nofm and timeconv --- appl/recommand/CommandProcessor.cpp | 44 ++++++++++++++++++++++++++++- appl/recommand/CommandProcessor.hpp | 1 + appl/recommand/mainwindow.ui | 8 +++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/appl/recommand/CommandProcessor.cpp b/appl/recommand/CommandProcessor.cpp index 1ffd867..9731c71 100644 --- a/appl/recommand/CommandProcessor.cpp +++ b/appl/recommand/CommandProcessor.cpp @@ -72,6 +72,8 @@ void CommandProcessor::statement(int lineNo, const QString& text){ euroJackpot(args); } else if (QString("lotto").startsWith(arg0)){ lotto(args); + } else if (QString("nofm").startsWith(arg0)){ + nOfM(args); } else if (QString("time").startsWith(arg0)){ time(args); } else { @@ -178,12 +180,37 @@ void CommandProcessor::lotto(const QStringList& args){ if (count > 0){ QString line; for (uint ix = 0; ix < count; ix++){ - line = QString::number(ix + 1) + ": " + calcNOfM(5, 50) + line = QString::number(ix + 1) + ": " + calcNOfM(6, 49) + " | " + calcNOfM(1, 10); out(line); } } } +/** + * Displays proposals for the Euro Jackpot. + * + * @param args the command arguments + */ +void CommandProcessor::nOfM(const QStringList& args){ + uint n, m; + if (args.count() < 3){ + help("too few parameter: expected", args); + } else { + QString arg1 = args.at(1); + QString arg2 = args.at(2); + if (ReQStringUtils::lengthOfUInt(arg1, 0, 10, &n) != arg1.length()){ + help("not a number: ", args); + } else if (ReQStringUtils::lengthOfUInt(arg2, 0, 10, &m) != arg2.length()){ + help("not a number: ", args); + } else if (n < 2){ + help(" < 2", args); + } else if (m < 2){ + help(" < ", args); + } else { + out(calcNOfM(n, m)); + } + } +} /** * Displays a time expression @@ -191,4 +218,19 @@ void CommandProcessor::lotto(const QStringList& args){ * @param args the command arguments */ void CommandProcessor::time(const QStringList& args){ + if (args.count() != 2){ + help("not one argument