repl.it
@kironroy/

TimeKeeper

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
  • notes.txt
  • TimeKeeper.cs
main.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
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimeKeeping {

 class Program {
  static void Main(string[] args) {
   var stopwatch = new StopWatch(); // creating an stopwatch object
   int choice; // declaring a var but not assinging it


   do // do loop
   {
    Console.Write("1: Start Stop watch\n2: Stop Stop watch\n3: Read time\n0 Quit\n ");
    choice = Convert.ToInt32(Console.ReadLine());

    switch (choice) {
     case 1:
      stopwatch.Start(); // method 1
      BreakLine();
      break;
     case 2:
      stopwatch.Stop(); // method 2
      BreakLine();
      break;
     case 3:
      Console.WriteLine(stopwatch.ElaspedTime()); // method 3
      BreakLine();
      break;
    }
   }

   while (choice != 0); // when 0 is pressed do loop with terminate
  }


  public static void BreakLine() => Console.WriteLine();
 }
}