From 5855b37c6e4c84675912bd23b7d9d2e7194da11c Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 11 May 2025 10:39:58 -0500 Subject: [PATCH] Added the type in to the print --- src/include/print.h | 5 ++++- src/print.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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; +}