Advertisement
Blizzardo1

A Message to the World

Aug 15th, 2020
1,591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. namespace AMessageToTheWorld {
  3.  
  4.     public delegate void WhomYouKnowYouShouldGoto();
  5.    
  6.     public static class Message2World {
  7.         private static Random _rand = new Random();
  8.         private static bool _enabled;
  9.         private static long _failCounter;
  10.         private static bool YouFail() => _failCounter > long.MaxValue / 2;
  11.  
  12.         private static void YourBest() {
  13.             Console.WriteLine("Without giving it your all, you will fall.");
  14.             _failCounter += _rand.Next(int.MinValue, int.MaxValue);
  15.         }
  16.  
  17.         private static void WhatYouNeedToDo() {
  18.             Console.WriteLine("Your Priorities are important right now.");
  19.             _failCounter += _rand.Next(int.MinValue, int.MaxValue);
  20.         }
  21.  
  22.         private static void EveryTimeYouFall() {
  23.             Console.WriteLine("Get up!");
  24.             _failCounter = 0;
  25.         }
  26.  
  27.         private static bool YouStillHaveTime() {
  28.             return (DateTime.MaxValue - DateTime.Now).TotalMilliseconds > 0;
  29.         }
  30.  
  31.         public static void Begin() {
  32.             _enabled = true;
  33.             static void Always() {
  34.                 try {
  35.                     YourBest();
  36.                     do {
  37.                         WhatYouNeedToDo();
  38.                     } while (YouStillHaveTime());
  39.                    
  40.                     if(YouFail())
  41.                         throw new Exception("All your worries");
  42.                 }
  43.                 catch (Exception yourself) {
  44.                     EveryTimeYouFall();
  45.                 }
  46.             }
  47.             WhomYouKnowYouShouldGoto _ = Always;
  48.             while (_enabled) _();
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement