Created
November 11, 2015 16:55
-
-
Save NULLx76/d27688a085101cd4758e to your computer and use it in GitHub Desktop.
printer error generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I'm fairly new to C++, please excuse the bad code. Just put this program into your compiler of choice, and let the hilarity ensue! | |
#include <iostream> | |
#include <string> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int random(int min, int max); //range : [min, max) | |
int main() | |
{ | |
string noun [10] = {"paper ", "tray ", "user ", "button ", "ink ", "toner ", "rack ", "spooler ", "printer ", "feeder "}; | |
string fault [10] = {"jam", "error", "fault", "overload", "spill", "failure", "spill", "low ", "leak ", "malfunction "}; | |
string action [10] = {"remove ", "reset ", "recalibrate ", "push ", "adjust ", "reload ", "dislodge ", "insert ", "retrieve ", "feed "}; | |
bool keepgoing = true; | |
char ch; | |
while (keepgoing == true) | |
{ | |
for(int i = 0; i < 10; i++) | |
{ | |
cout << "Error: "; | |
cout << noun[random(0, 10)]; | |
cout << fault[random(0,10)] << ": "; | |
cout << "Please "; | |
cout << action[random(0,10)]; | |
cout << noun[random(0, 10)] << endl; | |
} | |
cout << endl << "Press enter to generate more error messages"; | |
cin.get(ch); | |
} | |
return 0; | |
} | |
int random(int min, int max) //range : [min, max) | |
{ | |
static bool first = true; | |
if ( first ) | |
{ | |
srand(time(NULL)); //seeding for the first time only! | |
first = false; | |
} | |
return min + rand() % (max - min); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment