-
Notifications
You must be signed in to change notification settings - Fork 52
/
bottles.ps1
42 lines (30 loc) · 909 Bytes
/
bottles.ps1
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
<#
Author: Doug Finke
Email: finked@hotmail.com
Blog: https://dfinke.github.io/
Twitter: https://twitter.com/dfinke
GitHub: https://github.com/dfinke
YouTube: https://www.youtube.com/dougfinke
PowerShell Meetup: https://www.meetup.com/NycPowershellMeetup/
LinkedIn: https://www.linkedin.com/in/douglasfinke/
#>
param(
[ValidateRange(1, [int]::MaxValue)]
$num = 10
)
$result = for ($bottle = $num; $bottle -gt 0; $bottle--) {
$nextBottle = $bottle - 1
$s1 = ''
$s2 = ''
$numNext = 'No more'
if ($bottle -gt 1) { $s1 = 's' }
if ($nextBottle -ne 1) { $s2 = 's' }
if ($nextBottle -gt 0) { $numNext = $nextBottle }
@"
$bottle bottle$($s1) of beer on the wall,
$bottle bottle$($s1) of beer,
Take one down, pass it around,
$numNext bottle$($s2) of beer on the wall!
"@
}
-join $result