move GKI display to getReading
This commit is contained in:
parent
61a4c0dee6
commit
c778ec988b
34
main.go
34
main.go
@ -145,20 +145,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error getting reading: %s\n", err)
|
fmt.Printf("Error getting reading: %s\n", err)
|
||||||
} else {
|
} else {
|
||||||
// Display GKI and level of ketosis
|
|
||||||
fmt.Printf("\nYour GKI is: %0.2f\n", reading.GKI)
|
|
||||||
switch {
|
|
||||||
case reading.GKI <= 1:
|
|
||||||
fmt.Println("You're in the highest level of ketosis.")
|
|
||||||
case reading.GKI < 3:
|
|
||||||
fmt.Println("You're in a high therapeutic level of ketosis.")
|
|
||||||
case reading.GKI < 6:
|
|
||||||
fmt.Println("You're in a moderate level of ketosis.")
|
|
||||||
case reading.GKI <= 9:
|
|
||||||
fmt.Println("You're in a low level of ketosis.")
|
|
||||||
default:
|
|
||||||
fmt.Println("You are not in ketosis.")
|
|
||||||
}
|
|
||||||
appCtx.AddReading(reading)
|
appCtx.AddReading(reading)
|
||||||
}
|
}
|
||||||
case "2":
|
case "2":
|
||||||
@ -205,7 +191,25 @@ func getReading() (Reading, error) {
|
|||||||
return Reading{}, errors.New("ketone reading cannot be less than 0")
|
return Reading{}, errors.New("ketone reading cannot be less than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewReading(glucose, ketone), nil
|
reading := NewReading(glucose, ketone)
|
||||||
|
|
||||||
|
// Display GKI and level of ketosis
|
||||||
|
fmt.Printf("\nYour GKI is: %0.2f\n", reading.GKI)
|
||||||
|
switch {
|
||||||
|
case reading.GKI <= 1:
|
||||||
|
fmt.Println("You're in the highest level of ketosis.")
|
||||||
|
case reading.GKI < 3:
|
||||||
|
fmt.Println("You're in a high therapeutic level of ketosis.")
|
||||||
|
case reading.GKI < 6:
|
||||||
|
fmt.Println("You're in a moderate level of ketosis.")
|
||||||
|
case reading.GKI <= 9:
|
||||||
|
fmt.Println("You're in a low level of ketosis.")
|
||||||
|
default:
|
||||||
|
fmt.Println("You are not in ketosis.")
|
||||||
|
}
|
||||||
|
|
||||||
|
//return NewReading(glucose, ketone), nil
|
||||||
|
return reading, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserInput(prompt string) (string, error) {
|
func getUserInput(prompt string) (string, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user