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