package lasagna
// TODO: define the 'PreparationTime()' function
func PreparationTime(layers []string, avg_prep_time int) int {
if (avg_prep_time == 0 ) {
avg_prep_time = 2;
}
ret := (len(layers) * avg_prep_time);
return ret;
}
// TODO: define the 'Quantities()' function
func Quantities(layers []string) (int, float64) {
noodles := 0;
sauce := 0.0;
for i := 0 ; i < len(layers); i++ {
switch layers[i] {
case "noodles" : noodles += 50;
case "sauce" : sauce += 0.2
}
}
return noodles, sauce;
}
// TODO: define the 'AddSecretIngredient()' function
// AddSecretIngredient copies the last element from 'theirs' slice and appends it to the 'own' slice.
func AddSecretIngredient(theirs []string, own *[]string) {
*own = append(*own,theirs[len(theirs)-1]);
}
// TODO: define the 'ScaleRecipe()' function
func ScaleRecipe(quantities []float64, portions int) []float64 {
scaledQuantities := make([]float64, len(quantities))
for i, quantity := range quantities {
scaledQuantities[i] = quantity * float64(portions) / 2.0
}
return scaledQuantities
}
// Your first steps could be to read through the tasks, and create
// these functions with their correct parameter lists and return types.
// The function body only needs to contain panic("").
//
// This will make the tests compile, but they will fail.
// You can then implement the function logic one by one and see
// an increasing number of tests passing as you implement more
// functionality
Add Secret Ingredient doesnt go through test. What's the problem?