Hey again, I thought I will give a small tutorial how to make a ghostwritter. I have made this with some help of CC, so it turned out to be awsome.
So lets go on.
First lets build the input reader.
Now we would want to use the input data, so...Code:import java.util.*;//Using the scanner, instead of Keyboard reader public class ghostwritter { protected static Scanner sc = new Scanner(System.in);//Setting up scanner public static void main(String[] arg) throws InterruptedException { System.out.println("Type in something ");//The input reader
Now on to the function, we want it to type out letter by letter with a delay. What I call a "ghostwritter"Code:String x = sc.nextLine();//This will allow the input data to be used(Note input was a string and will be used as a string)
So here is the whole codeCode:for(int i=0; i<x.length(); i++) {//A loop thru the entire string System.out.print(x.charAt(i));//Catching very "x" one by one Thread.sleep(1000);//Put every "x" out it with one second delay(1000ms = 1 s) } } }
Hope it will be useful, and again sorry for my weak explaination...Code:import java.util.*; public class ghostwritter { protected static Scanner sc = new Scanner(System.in); public static void main(String[] arg) throws InterruptedException { System.out.println("Type in something "); String x = sc.nextLine(); for(int i=0; i<x.length(); i++) { System.out.print(x.charAt(i)); Thread.sleep(1000); } } }
I saw your code, was bored, and thought I'd show people how to do it in C++.
Here it is....
Code:/* "Ghost Writer" In C++ */ #include <iostream> #include <windows.h> #include <conio.h> using namespace std; int main() { char the_phrase[10000]; int i; cout << "Enter a phrase you want to see outputted by the Ghost Writer: "; cin.get(the_phrase, 10000); cout << "\n\n"; for (i = 0; i < strlen(the_phrase); i++) { cout << the_phrase[i]; Sleep(100); } getch(); return 0; }
Lol well I didn't want to start my own topic and write a full tutorial and all, so I figured this was the best place for it.
Nice tutorial/code Turk4n, +rep.
Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks