golang-exercises/star-shapes/main.go

58 lines
998 B
Go

package main
// TODO: figure out colored text
import (
"fmt"
)
func main() {
var numStar int
var numShape int
// TODO: Add error handling for star number
forStars:
for {
fmt.Println("How many stars do you want?")
fmt.Printf(" Stars: ")
fmt.Scan(&numStar)
// This is confusing
// switch v := interface{}(numStar).(type) {
// case int:
// break forStars
// default:
// fmt.Printf("ERROR, %v is invalid input", v)
// panic("ERROR")
// }
if numStar >= 0 {
break forStars
} else {
fmt.Printf("\n[-] INVALID NUMBER\n\n")
}
}
forShapes:
for {
fmt.Println("Which shape would you like?\n Line [1]\n Square [2]\n Flag [3]")
fmt.Printf("Shape: ")
fmt.Scanln(&numShape)
fmt.Printf("\n")
switch numShape {
case 1:
line(numStar)
break forShapes
case 2:
square(numStar)
break forShapes
case 3:
flag(numStar)
break forShapes
default:
fmt.Printf("\n[-] INVALID INPUT, please use either 1, 2 or 3.\n\n")
}
}
}