Files
learngo/15-arrays-project-clock/02-printing-the-clock/main.go
2018-12-15 13:34:39 +03:00

124 lines
1.9 KiB
Go

// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// ★★★★★★★★★★★★★★★★★★★★★★★★★★★
// ★ GOAL 2 : Printing the Clock
// ★★★★★★★★★★★★★★★★★★★★★★★★★★★
//
// 1. Get the current time
//
// 2. Get the current hour, minute and second from the current time
//
// 3. Create the clock array by getting the digits from the digits array
//
// 4. Print the clock by using the clock array
//
// 5. Create a separator array (it's also a placeholder type)
//
// 6. Add the separators into the correct positions of the clock array
package main
import (
"fmt"
)
func main() {
type placeholder [5]string
zero := placeholder{
"███",
"█ █",
"█ █",
"█ █",
"███",
}
one := placeholder{
"██ ",
" █ ",
" █ ",
" █ ",
"███",
}
two := placeholder{
"███",
" █",
"███",
"█ ",
"███",
}
three := placeholder{
"███",
" █",
"███",
" █",
"███",
}
four := placeholder{
"█ █",
"█ █",
"███",
" █",
" █",
}
five := placeholder{
"███",
"█ ",
"███",
" █",
"███",
}
six := placeholder{
"███",
"█ ",
"███",
"█ █",
"███",
}
seven := placeholder{
"███",
" █",
" █",
" █",
" █",
}
eight := placeholder{
"███",
"█ █",
"███",
"█ █",
"███",
}
nine := placeholder{
"███",
"█ █",
"███",
" █",
"███",
}
digits := [...]placeholder{
zero, one, two, three, four, five, six, seven, eight, nine,
}
for line := range digits[0] {
for digit := range digits {
fmt.Print(digits[digit][line], " ")
}
fmt.Println()
}
}