Tweaking and improving UX
This commit is contained in:
parent
cfaf807701
commit
20a539b9c4
|
@ -14,12 +14,16 @@ var choice int8
|
|||
var numToAdd float64
|
||||
var notaSumada float64
|
||||
|
||||
func clear() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
}
|
||||
|
||||
func main() {
|
||||
start()
|
||||
}
|
||||
|
||||
func start() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
msg()
|
||||
choices()
|
||||
}
|
||||
|
@ -28,7 +32,7 @@ func msg() {
|
|||
println("[1] Add grade to vector")
|
||||
println("[2] View grades")
|
||||
println("[3] Get grade average")
|
||||
println("[4] Get min and max grade")
|
||||
println("[4] Get min / max grade")
|
||||
println("[5] Reset grades")
|
||||
println("[6] Exit")
|
||||
}
|
||||
|
@ -36,7 +40,7 @@ func msg() {
|
|||
func choices() {
|
||||
for {
|
||||
fmt.Printf("Choice: ")
|
||||
fmt.Scanln(&choice)
|
||||
fmt.Scan(&choice)
|
||||
switch choice {
|
||||
case 1:
|
||||
addVec()
|
||||
|
@ -62,7 +66,7 @@ func total(num float64) {
|
|||
}
|
||||
|
||||
func average() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
msg()
|
||||
|
||||
for _, elem := range notas {
|
||||
|
@ -70,44 +74,59 @@ func average() {
|
|||
}
|
||||
|
||||
notaMedia := notaSumada / float64(len(notas))
|
||||
fmt.Printf("\n-----------------------------------------------")
|
||||
fmt.Printf("\nAll your grades combine to %v\n", notaSumada)
|
||||
fmt.Printf("Your average grade is %v\n\n", notaMedia)
|
||||
fmt.Printf("Your average grade is %v\n", notaMedia)
|
||||
fmt.Printf("-----------------------------------------------\n\n")
|
||||
|
||||
notaSumada = 0
|
||||
notaMedia = 0
|
||||
}
|
||||
|
||||
func min(num float64) {
|
||||
|
||||
}
|
||||
|
||||
func max(num float64) {
|
||||
func minmax() {
|
||||
|
||||
}
|
||||
|
||||
func resetGrades() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
msg()
|
||||
fmt.Printf("\nYour grades have been reset!\n\n")
|
||||
fmt.Printf("\n-----------------------------------------------")
|
||||
fmt.Printf("\nYour grades have been reset!\n")
|
||||
fmt.Printf("-----------------------------------------------\n\n")
|
||||
notas = nil
|
||||
}
|
||||
|
||||
func addVec() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
fmt.Println("Add a number to your vector")
|
||||
fmt.Printf("Number: ")
|
||||
fmt.Scanln(&numToAdd)
|
||||
|
||||
// TODO: get error handling going after initial functionality is done
|
||||
// if len(numToAdd) == 0 {
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
|
||||
notas = append(notas, numToAdd)
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
msg()
|
||||
fmt.Printf("\nYou have added the number %v\n\n", numToAdd)
|
||||
fmt.Printf("\n-----------------------------------------------")
|
||||
fmt.Printf("\nYou have added the number %v\n", numToAdd)
|
||||
fmt.Printf("-----------------------------------------------\n\n")
|
||||
|
||||
numToAdd = 0
|
||||
}
|
||||
|
||||
func viewGrades() {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
clear()
|
||||
msg()
|
||||
fmt.Println("\nThese are your grades:")
|
||||
fmt.Printf("\n-----------------------------------------------\n")
|
||||
fmt.Printf("These are your grades:")
|
||||
fmt.Printf("\n-----------------------------------------------\n")
|
||||
for _, elem := range notas {
|
||||
fmt.Println(elem)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Printf("-----------------------------------------------\n\n")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue