Created
February 16, 2016 02:13
-
-
Save JFFail/88b211d3d16033510070 to your computer and use it in GitHub Desktop.
Silly script to figure out where state employees will go to lunch based on whether or not it's pay day!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Making a class for where state employees go for lunch. This does NOT account for holidays affecting when you get paid. | |
class StateEmployee | |
{ | |
#Base properties. | |
[string] $firstName = "" | |
[string] $lastName = "" | |
[bool] $payDay = $false | |
#Default empty constructor. Seriously, don't use this. | |
StateEmployee() | |
{ | |
$this.GetMonies() | |
} | |
#Overloaded constructor. Use this one, for great justice! | |
StateEmployee([string]$first, [string]$last) | |
{ | |
$this.firstName = $first | |
$this.lastName = $last | |
$this.GetMonies() | |
} | |
#Function to determine if it's payday. | |
[void] GetMonies() | |
{ | |
#What's the day of the month? | |
$dayOfMonth = (Get-Date).Day | |
$dayOfWeek = (Get-Date).DayOfWeek | |
#Figure out if it's a leap year. | |
$thisMonth = (Get-Date).Month | |
$isLeapYear = $false | |
#Do leap year shit. | |
$thisYear = (Get-Date).Year | |
if(($thisMonth % 4) -ne 0) | |
{ | |
$isLeapYear = $false | |
} | |
elseif(($thisYear % 100) -ne 0) | |
{ | |
$isLeapYear = $true | |
} | |
elseif(($thisYear % 400) -ne 0) | |
{ | |
$isLeapYear = $false | |
} | |
else | |
{ | |
$isLeapYear = $true | |
} | |
#Now figure out if they get f'in paid! | |
#Is it February? | |
if($thisMonth -eq 2) | |
{ | |
#Can we all agree that February sucks? Thanks. | |
if(-not($isLeapYear)) | |
{ | |
if((($dayOfMonth -eq 15) -or ($dayOfMonth -eq 28)) -and (($dayOfWeek -ne "Saturday") -and ($dayOfWeek -ne "Sunday"))) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 14) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 16) -and ($dayOfWeek -eq "Monday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 27) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
else | |
{ | |
#The 1st on a Monday or Tuesday will NEVER be payday. If it's Monday, then Friday, Jan. 29th is payday. If it's Sunday, | |
# then Monday, January 31st is payday. | |
$this.payDay = $false | |
} | |
} | |
else | |
{ | |
#Seriously, F leap years. | |
if((($dayOfMonth -eq 15) -or ($dayOfMonth -eq 29)) -and (($dayOfWeek -ne "Saturday") -and ($dayOfWeek -ne "Sunday"))) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 14) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 16) -and ($dayOfWeek -eq "Monday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 28) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
else | |
{ | |
#The 1st on a Monday or Tuesday will NEVER be payday. If it's Monday, then Friday, Jan. 29th is payday. If it's Sunday, | |
# then Monday, January 31st is payday. | |
$this.payDay = $false | |
} | |
} | |
} | |
else | |
{ | |
#Figure out how many days the month can possibly have. Skip February. That guy's a douche. | |
#CRAP. So this needs to be for the month PRIOR since it only matters for the 1st. Adjust all by 1. | |
if($thisMonth -eq 1) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 2) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 3) | |
{ | |
if($isLeapYear) | |
{ | |
$maxDays = 29 | |
} | |
else | |
{ | |
$maxDays = 28 | |
} | |
} | |
elseif($thisMonth -eq 4) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 5) | |
{ | |
$maxDays = 30 | |
} | |
elseif($thisMonth -eq 6) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 7) | |
{ | |
$maxDays = 30 | |
} | |
elseif($thisMonth -eq 8) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 9) | |
{ | |
$maxDays = 31 | |
} | |
elseif($thisMonth -eq 10) | |
{ | |
$maxDays = 30 | |
} | |
elseif($thisMonth -eq 11) | |
{ | |
$maxDays = 31 | |
} | |
else | |
{ | |
$maxDays = 30 | |
} | |
#Is it the 15th or the 30th and *not* a freakin' weekend? | |
if((($dayOfMonth -eq 15) -or ($dayOfMonth -eq 30)) -and (($dayOfWeek -ne "Saturday") -and ($dayOfWeek -ne "Sunday"))) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 14) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 16) -and ($dayOfWeek -eq "Monday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 29) -and ($dayOfWeek -eq "Friday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 31) -and ($dayOfWeek -eq "Monday")) | |
{ | |
$this.payDay = $true | |
} | |
elseif(($dayOfMonth -eq 1) -and ($dayOfWeek -eq "Monday") -and ($maxDays -eq 30)) | |
{ | |
$this.payDay = $true | |
} | |
else | |
{ | |
$this.payDay = $false | |
} | |
} | |
} | |
[string] GetFirst() | |
{ | |
return $this.firstName | |
} | |
[string] GetLast() | |
{ | |
return $this.lastName | |
} | |
[bool] GetPayDay() | |
{ | |
return $this.payDay | |
} | |
} | |
#Make a state employee. | |
$employee = [StateEmployee]::new("Bogan", "Lales") | |
#Can run $employee.GetPayDay() at later dates outside of the constructor if necessary. | |
$firstName = $employee.GetFirst() | |
$lastName = $employee.GetLast() | |
#Display stuff to the user. | |
Write-Output "Want to know where $firstName $lastName went to lunch?" | |
if($employee.GetPayDay()) | |
{ | |
Write-Output "$firstName went to Ginza! The Japanese cuisine was exquisite and the sake plentiful!" | |
} | |
else | |
{ | |
#Everyone has a lucky break sometimes. Check the couch cushions for change! | |
$randomNumber = Get-Random -SetSeed (Get-Date).Millisecond -Minimum 1 -Maximum 100 | |
if($randomNumber % 7 -eq 0) | |
{ | |
Write-Output "$firstName caught a lunch break and got food from Thai Smile! Clash of Clans was being played there." | |
} | |
else | |
{ | |
Write-Output "Eww... $firstName had a stank salad from Transpo... The struggle is real." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment