summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blarandom.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/blarandom.cpp b/blarandom.cpp
index 1d99e05..aa6edfd 100644
--- a/blarandom.cpp
+++ b/blarandom.cpp
@@ -27,6 +27,7 @@
v0.4 - Added coin & dice presets
v0.5 - Added 8ball preset
v0.6 - Can now use count with presets
+ v0.61 - Added error handling for 8ball, removed ability to count
*/
@@ -39,7 +40,7 @@
int main() {
- std::string version = "0.6";
+ std::string version = "0.61";
RandomLib::Random r; // Create r
r.Reseed(); // and give it a unique seed
@@ -47,7 +48,7 @@ int main() {
fgets(input, 100, stdin);
std::string strInput = input;
- std::string args[10] = { "" };
+ std::string args[30] = { "" };
std::istringstream iss(strInput);
@@ -113,9 +114,18 @@ int main() {
min = 0;
max = 17;
eightball = true;
+ std::string question = "";
+ for (int i = 1; i < 30; i++) {
+ question += args[i];
+ }
+ if (question.length() == 0 ||
+ question.substr(question.length()-1, 1).compare("?")) {
+ std::cout << "Ask a question!" << std::endl;
+ return 1;
+ }
}
- if (coin || dice || letter || d20 || eightball) {
+ if (coin || dice || letter || d20) {
if (args[1].empty()) {
count = 1;
} else {