golang-exercises/star-shapes/shapes.go

43 lines
687 B
Go

package main
import (
"fmt"
"time"
)
var delayer time.Duration = 50
// Drawing a line of asterisks
func line(num int) {
for i := 0; i < num; i++ {
fmt.Printf("* ")
time.Sleep(delayer * time.Millisecond)
}
fmt.Printf("\n")
}
// Drawing a square of asterisks
func square(num int) {
for i := 0; i < num; i++ {
for i := 0; i < num; i++ {
fmt.Printf("* ")
time.Sleep(delayer * time.Millisecond)
}
fmt.Printf("\n")
}
}
// Drawing a flag of asterisks
func flag(num int) {
for a := 0; a < num; a++ {
for i := -1; i < a; i++ {
fmt.Printf("* ")
time.Sleep(delayer * time.Millisecond)
}
fmt.Printf("\n")
}
for i := 0; i < num/2; i++ {
println("*")
}
}