diff --git a/cout-recette.hs b/cout-recette.hs index 9179e6d..a23ca2a 100755 --- a/cout-recette.hs +++ b/cout-recette.hs @@ -18,9 +18,11 @@ recipeCost (Recipe _ bom _ _) = sum . map ingredientCost $ bom ingredientCost :: UsedIngredient -> Double ingredientCost (UsedIngredient (Ingredient _ uCost) qtt) = uCost * qtt -prixLitre prixTotal quantiteLessive = prixTotal / quantiteLessive +unitCost :: Recipe -> Double -> Double +unitCost (Recipe _ _ qtt _) totalCost = totalCost / qtt -prixUtilisation prixTotal quantiteLessive = prixTotal / nombreUtilisations +useCost :: Recipe -> Double -> Double +useCost (Recipe _ _ _ uses) totalCost = totalCost / uses eau = Ingredient "Eau" 0.003 savonMarseille = Ingredient "Savon de Marseille" 3.36 @@ -37,14 +39,14 @@ lessive = Recipe "Lessive" 2.5 30 -quantiteLessive = 2.5 -nombreUtilisations = 30 - main = do putStrLn "Calcul du coût des recettes\n" putStrLn "* Lessive :" print lessive - putStrLn $ " * Prix Total = " ++ show (recipeCost lessive) ++ "€" --- putStrLn $ " * Prix au litre = " ++ show prixLitre ++ "€" --- putStrLn $ " * Prix par utilisation = " ++ show prixUtilisation ++ "€" + let lessiveTotalCost = recipeCost lessive + lessiveUnitCost = unitCost lessive lessiveTotalCost + lessiveUseCost = useCost lessive lessiveTotalCost + putStrLn $ " * Prix Total = " ++ show lessiveTotalCost ++ "€" + putStrLn $ " * Prix au litre = " ++ show lessiveUnitCost ++ "€" + putStrLn $ " * Prix par utilisation = " ++ show lessiveUseCost ++ "€"