-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoBasicEx.go
29 lines (23 loc) · 931 Bytes
/
goBasicEx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import "fmt"
const OvenTime = 40
// RemainingOvenTime returns the remaining minutes based on the `actual` minutes already in the oven.
func RemainingOvenTime(actualMinutesInOven int) int {
if actualMinutesInOven>OvenTime {
return 0
}
return OvenTime-actualMinutesInOven
}
// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers.
func PreparationTime(numberOfLayers int) int {
return numberOfLayers*2
}
// ElapsedTime calculates the time elapsed cooking the lasagna. This time includes the preparation time and the time the lasagna is baking in the oven.
func ElapsedTime(numberOfLayers, actualMinutesInOven int) int {
return PreparationTime(numberOfLayers)+actualMinutesInOven
}
func main() {
fmt.Println("Remaining time in oven:", RemainingOvenTime(30))
fmt.Println("Preparation time:", PreparationTime(2))
fmt.Println("Elapsed time:", ElapsedTime(2, 30))
}