Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
79
Task/Nautical-bell/PowerShell/nautical-bell.psh
Normal file
79
Task/Nautical-bell/PowerShell/nautical-bell.psh
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
function Get-Bell
|
||||
{
|
||||
[CmdletBinding()]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
Position=0)]
|
||||
[ValidateRange(1,12)]
|
||||
[int]
|
||||
$Hour,
|
||||
|
||||
[Parameter(Mandatory=$true,
|
||||
Position=1)]
|
||||
[ValidateSet(0,30)]
|
||||
[int]
|
||||
$Minute
|
||||
)
|
||||
|
||||
$bells = @{
|
||||
OneBell = 1
|
||||
TwoBells = 2
|
||||
ThreeBells = 2, 1
|
||||
FourBells = 2, 2
|
||||
FiveBells = 2, 2, 1
|
||||
SixBells = 2, 2, 2
|
||||
SevenBells = 2, 2, 2, 1
|
||||
EightBells = 2, 2, 2, 2
|
||||
}
|
||||
|
||||
filter Invoke-Bell
|
||||
{
|
||||
if ($_ -eq 1)
|
||||
{
|
||||
[System.Media.SystemSounds]::Asterisk.Play()
|
||||
Write-Host -NoNewline "♪"
|
||||
}
|
||||
else
|
||||
{
|
||||
[System.Media.SystemSounds]::Exclamation.Play()
|
||||
Write-Host -NoNewline "♪♪ "
|
||||
}
|
||||
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
|
||||
|
||||
$time = New-TimeSpan -Hours $Hour -Minutes $Minute
|
||||
|
||||
switch ($time.Hours)
|
||||
{
|
||||
1 {if ($time.Minutes -eq 0) {$bells.TwoBells | Invoke-Bell} else {$bells.ThreeBells | Invoke-Bell}; break}
|
||||
2 {if ($time.Minutes -eq 0) {$bells.FourBells | Invoke-Bell} else {$bells.FiveBells | Invoke-Bell}; break}
|
||||
3 {if ($time.Minutes -eq 0) {$bells.SixBells | Invoke-Bell} else {$bells.SevenBells | Invoke-Bell}; break}
|
||||
4 {if ($time.Minutes -eq 0) {$bells.EightBells | Invoke-Bell} else {$bells.OneBell | Invoke-Bell}; break}
|
||||
5 {if ($time.Minutes -eq 0) {$bells.TwoBells | Invoke-Bell} else {$bells.ThreeBells | Invoke-Bell}; break}
|
||||
6 {if ($time.Minutes -eq 0) {$bells.FourBells | Invoke-Bell} else {$bells.FiveBells | Invoke-Bell}; break}
|
||||
7 {if ($time.Minutes -eq 0) {$bells.SixBells | Invoke-Bell} else {$bells.SevenBells | Invoke-Bell}; break}
|
||||
8 {if ($time.Minutes -eq 0) {$bells.EightBells | Invoke-Bell} else {$bells.OneBell | Invoke-Bell}; break}
|
||||
9 {if ($time.Minutes -eq 0) {$bells.TwoBells | Invoke-Bell} else {$bells.ThreeBells | Invoke-Bell}; break}
|
||||
10 {if ($time.Minutes -eq 0) {$bells.FourBells | Invoke-Bell} else {$bells.FiveBells | Invoke-Bell}; break}
|
||||
11 {if ($time.Minutes -eq 0) {$bells.SixBells | Invoke-Bell} else {$bells.SevenBells | Invoke-Bell}; break}
|
||||
12 {if ($time.Minutes -eq 0) {$bells.EightBells | Invoke-Bell} else {$bells.OneBell | Invoke-Bell}}
|
||||
}
|
||||
|
||||
Write-Host
|
||||
}
|
||||
|
||||
Write-Host "Time Bells`n---- -----`n"
|
||||
|
||||
1..12 | ForEach-Object {
|
||||
|
||||
$date = Get-Date -Hour $_ -Minute 0
|
||||
Write-Host -NoNewline "$($date.ToString("hh:mm")) "
|
||||
Get-Bell -Hour $_ -Minute 0
|
||||
|
||||
$date = $date.AddMinutes(30)
|
||||
Write-Host -NoNewline "$($date.ToString("hh:mm")) "
|
||||
Get-Bell -Hour $_ -Minute 30
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue