-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
112 lines (93 loc) · 2.93 KB
/
Copy pathProgram.cs
File metadata and controls
112 lines (93 loc) · 2.93 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.Threading;
using System.Text.RegularExpressions;
internal class Program
{
private static void Main(string[] args)
{
Menu();
Console.ReadKey();
}
static void Menu(){
string? tmp;
string UnidTempo;
int s,m;
Console.WriteLine("\n ///////CRONOMETRO//////////\n");
Console.WriteLine("\n s = segundos(S)");
Console.WriteLine("\n m = minutos (M)");
Comeco:
Console.Write("tmp: ");
tmp = Console.ReadLine();
if(tmp != null){
UnidTempo = tmp.Substring(tmp.Length -1);//.length é a quantidade de caracteres que a string tem, ex: 120s<<possui 4 caracter.
if (!Regex.IsMatch(UnidTempo, @"[0_9]+#~"))
{
s = int.Parse(tmp.Substring(0, tmp.Length - 1));
m = int.Parse(tmp.Substring(0, tmp.Length - 1));
}
else
{
goto Comeco;}
PreStart();
Start(UnidTempo,m,s);
}
static void PreStart(){
Console.WriteLine("Iniciando...");
Thread.Sleep(1000);
}
}
private static void Start(string unidTempo, int s, int m)
{
int Segundos = 59;
Console.Clear();
if (unidTempo == "m")
{
Console.Write(m + unidTempo);
s = m*60;
Thread.Sleep(1000);
m--;
Console.Clear();
while (m >= 0)
{
Console.WriteLine("{0}{1} {2}{3}", m, unidTempo, Segundos, "s");
Thread.Sleep(1000);
Segundos--;
Console.Clear();
if (m > 0 && Segundos == 0)
{
Console.WriteLine("{0}{1} {2}{3}", m, unidTempo, Segundos, "s");
Thread.Sleep(1000);
m--;
Segundos = 59;
Console.Clear();
while (Segundos > 0)
{
Console.WriteLine("{0}{1} {2}{3}", m, unidTempo, Segundos, "s");
Thread.Sleep(1000);
Segundos--;
Console.Clear();
}
}
if (m == 0 && Segundos == 0)
{
Console.WriteLine(" *****fim***** ");
break;
}
}
}
if (unidTempo == "s")
{
while (s > 0)
{
Console.Write(s + unidTempo);
Thread.Sleep(1000);
s--;
Console.Clear();
if (s == 0)
{
Console.WriteLine("*****fim***** ");
}
}
}
}
}