Finished exercise and improved error handling
This commit is contained in:
parent
d9f17e78a3
commit
c33ebb25f0
|
@ -1,32 +1,42 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
// TODO: figure out colored text
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var numStar int
|
||||
var numShape int
|
||||
|
||||
// TODO: Add error handling for star number
|
||||
fmt.Println("How many stars do you want?")
|
||||
fmt.Printf(" Stars: ")
|
||||
fmt.Scan(&numStar)
|
||||
|
||||
fmt.Printf("\n")
|
||||
|
||||
fmt.Println("Which shape would you like?\n Line [1]\n Square [2]\n Flag [3]")
|
||||
fmt.Printf("Shape: ")
|
||||
fmt.Scan(&numShape)
|
||||
|
||||
switch numShape {
|
||||
case 1:
|
||||
println("Line")
|
||||
case 2:
|
||||
fmt.Println("Square")
|
||||
case 3:
|
||||
fmt.Println("Flag")
|
||||
default:
|
||||
fmt.Println("Invalid input, please use either 1, 2 or 3.")
|
||||
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")
|
||||
}
|
||||
}
|
||||
//flag(numStar)
|
||||
}
|
||||
|
||||
func line(num int) {
|
||||
|
|
Loading…
Reference in New Issue