Skip to content

Instantly share code, notes, and snippets.

@mperlet

mperlet/cpp_ex4.cpp

Created Nov 3, 2015
Embed
What would you like to do?
#include <stdio.h>
#include <iostream>
#include <unistd.h>
using namespace std;
class programming
{
private:
int variable;
public:
int state;
programming(){
state= 0;
}
void next_state()
{
switch ( state )
{
case 0 : cout << "R__\n"; break;
case 1: cout << "RY_\n"; break;
case 2: cout << "__G\n"; break;
case 3: cout << "_Y_\n"; state = -1; break;
default: cout << "error"; break;
}
state++;
}
};
main()
{
programming *obj = new programming();
while(true)
{
printf("\e[1;1H\e[2J"); // clear terminal hackkkkk
obj->next_state();
usleep(1000*1000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment