Advertisement
miroLLL

BeerTime

Sep 26th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Globalization;
  4.  
  5. class BeerTime
  6. {
  7.     static void Main()
  8.     {
  9.         Console.WriteLine("Please enter the time, when you available for beer... :)");
  10.         Console.Write("I'm available in ");
  11.         try
  12.         {
  13.             DateTime userInput = DateTime.Parse(Console.ReadLine());
  14.             DateTime beerTimeStart = Convert.ToDateTime("01:00 PM");
  15.             DateTime beerTimeEnd = Convert.ToDateTime("03:00 AM").AddHours(24);
  16.             if (userInput.Hour == 00 || userInput.Hour < 03)
  17.             {
  18.                 userInput = userInput.AddDays(1);
  19.             }
  20.             bool beerTime = userInput >= beerTimeStart && userInput <= beerTimeEnd;
  21.             if (beerTime)
  22.             {
  23.                 Console.WriteLine("Its Beer Time...");
  24.                 Console.WriteLine("Now get a beer and come to TOAST!");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine("Its not beer time yet.");
  29.                 Console.WriteLine("Try after {0:HH:mm} PM and before {1:HH:mm} AM", beerTimeStart, beerTimeEnd);
  30.             }
  31.         }
  32.         catch
  33.         {
  34.             Console.WriteLine("I said enter the time you are available for drinking beer, not some bullshit.");
  35.             Console.WriteLine("Probably you are drunk.. Go home to sleep and try later.");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement