-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRsvp.cs
35 lines (31 loc) · 828 Bytes
/
Rsvp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.IO;
using System.Threading;
namespace RSVPReader
{
class Rsvp
{
public static void Read(double wordsPerMinute, string text)
{
Console.CursorVisible = false;
double sec = (1.0 / (wordsPerMinute / 60.0));
long wpm = ((long)(sec * 1000));
Console.WriteLine("Press Enter to start reading.");
Console.ReadLine();
Console.Clear();
foreach (string word in text.Split(' '))
{
Console.Write($"\r{ new string(' ', Console.WindowWidth - 1)} \r");
Console.Write($"{new string(' ', Console.WindowWidth / 2)}{word}");
Thread.Sleep((int)wpm);
}
Console.Clear();
Console.CursorVisible = true;
}
public static void ReadFromFile(double wordsPerMinute, string filePath)
{
string text = File.ReadAllText(filePath);
Read(wordsPerMinute, text);
}
}
}