diff --git a/src/include/print.h b/src/include/print.h index 88b1f64..1cf3eee 100644 --- a/src/include/print.h +++ b/src/include/print.h @@ -1,5 +1,7 @@ #include #include +#include +#include using namespace std; class Print{ @@ -12,5 +14,6 @@ class Print{ }; void printl(string text); void println(string text); - + static void type(string text); + }; diff --git a/src/print.cpp b/src/print.cpp index 9b7f4dc..af5d0a9 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -7,3 +7,20 @@ void Print::printl(string text){ void Print::println(string text){ cout << text << endl; } + +void Print::type(string text){ + int a = text.size(); + char* charArray = new char[a+1]; + strcpy(charArray, text.c_str()); + int i = 0; + int time = 300; + + while(i < a+1){ + std::this_thread::sleep_for(std::chrono::milliseconds(time)); + cout << charArray[i] << flush; + i++; + + } + cout << endl; + delete[] charArray; +}