<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d4664242383901968618\x26blogName\x3dYO-pot\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLACK\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://yopot.blogspot.com/search\x26blogLocale\x3dro\x26v\x3d2\x26homepageUrl\x3dhttps://yopot.blogspot.com/\x26vt\x3d4354616304130766826', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

YO-pot

yo pot... tu poti... noi poate !!!

My job simulator or the geek way of thinking about life

sâmbătă, 15 noiembrie 2008

I have to admit, I am a bit ashamed of my self, better said, ashamed of my geekines... again.
While waiting for my colleagues to shut down their computers, after a long day at work I put together a few lines of code to depict the fact that after a day of work it was time to go home.
And sent these to them. And waited for the reaction. Which came. In the form of "Ha ha ha" and "you lost it" and so on. You've got the picture.
But that is ancient history in IT time (2-3 weeks old).
Yesterday, during a wall staring session I thought I could do better then 10 lines of uncompilable code, right?
Thus "My job simulator" was born. It's still in pre alfa, so bare with me.
You can get the .cs file from here. It's C# .NET code.

using System;
using System.Collections.Generic;
using System.Text;


namespace Work
{
///
/// This is my job simulator. Using highly advanced methods, like going to work, I've
/// managed to put together this incredible program. It will simulate with unbelievable
/// accuracy a typical work or weekend day.
/// Just put in the configuration section your data and watch it go!
/// After you will be astonished by the accuracy, you can always donate to keep the project
/// alive!
///

class Job
{
public static DateTime TimeToGoHome;
public static DateTime Today;
public static int CheckClockStep;
public static bool IsJobCool = false;
private static bool IsTimeToGoHome = false; //Used for very complicated calculations
private static int Chance; // Used in highly advanced algorithms.
private static Random _Random = new Random(); // Used in highly advanced algorithms.

static void Main(string[] args)
{
//Configuration Section - Replace with your own values//
// Today's date and hour. Format year, month, day, hour, second, millisecond
Today = new DateTime(2008,11,14,9,2,35,14);
// Time when you go home. Format year, month, day, hour, second, millisecond
TimeToGoHome = new DateTime(Today.Year, Today.Month, Today.Day, 18, 0, 0, 0);
// How long you can resist without checking what time is it.
CheckClockStep = 20;
// Do you thing your job is cool?!? Do you?
IsJobCool = false;

Console.WriteLine("Today is " + Today.DayOfWeek.ToString() + "!");

if (Today.DayOfWeek != DayOfWeek.Saturday && Today.DayOfWeek !=
DayOfWeek.Sunday)
GoWork();
else
BeHappy();

Console.ReadLine();
}

private static void GoWork()
{
//We all know how things are on Friday...
if (Today.DayOfWeek == DayOfWeek.Friday)
CheckClockStep = 10;

//Nothing works n the first 2 hours anyway, why bother?
if (Today.DayOfWeek == DayOfWeek.Monday)
Today.AddHours(2);

IsTimeToGoHome = WorkOne();

if (IsTimeToGoHome)
Console.WriteLine("HOME!");
else
Console.WriteLine("Something Broke! If I'm quick nobody will notice, going home...");
}

private static void BeHappy()
{
Chance = RandomNumber(0, 100);
if (IsJobCool)
{
if (Chance > 99)
{
IsJobCool = false;
Console.WriteLine("job's not cool anymore");
Console.WriteLine("Working...");
}
else
Console.WriteLine("Enjoying life");
}
else
Console.WriteLine("Enjoying life");
}

private static bool WorkOne()
{
try
{
while (Today < TimeToGoHome)
{
Chance = RandomNumber(1,10);

if (IsJobCool)
{
if (Chance <>
Console.WriteLine("Actually Working");
else
Console.WriteLine("Annoing friends by telling how cool my job is");
}
else
{
if (Chance == 1)
Console.WriteLine("Having Coffee");
else if (Chance == 2)
Console.WriteLine("Reading Emails");
else if (Chance == 3)
Console.WriteLine("Reading Blogs");
else if (Chance == 4)
Console.WriteLine("Twitting");
else if (Chance == 5)
Console.WriteLine("Helping Colleagues");
else if (Chance == 6)
{
int CanWin = RandomNumber(0, 100);
Console.WriteLine("Having an argument with my boss and...");
if (CanWin <>
Console.WriteLine("... winning");
else if (CanWin >= 51)
Console.WriteLine("... losing");
}
else if (Chance == 7)
Console.WriteLine("Staring at the monitor");
else if (Chance == 8)
Console.WriteLine("Working...");
else
Console.WriteLine("Trying to look like actually working");
}

Today = Today.AddMinutes(CheckClockStep);
}
}
catch
{
//Something Broke
return false;
}
return true;
}

private static int RandomNumber(int Min, int Max) {

return _Random.Next(Min, Max);
}
}
}

This code compiles and runs. If you run it, you will be amzaed by the astonishing accuracy.
Next version may never come...


Etichete: , , , , ,

posted by Liviu

0 Comments:

Add a comment

octombrie 2008
noiembrie 2008
decembrie 2008