supplementary calculations (cost per unit and cost per usage)

master
Yves Dubromelle 9 years ago
parent e6ab8cddc7
commit 04c07e87c1

@ -18,9 +18,11 @@ recipeCost (Recipe _ bom _ _) = sum . map ingredientCost $ bom
ingredientCost :: UsedIngredient -> Double ingredientCost :: UsedIngredient -> Double
ingredientCost (UsedIngredient (Ingredient _ uCost) qtt) = uCost * qtt 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 eau = Ingredient "Eau" 0.003
savonMarseille = Ingredient "Savon de Marseille" 3.36 savonMarseille = Ingredient "Savon de Marseille" 3.36
@ -37,14 +39,14 @@ lessive = Recipe "Lessive"
2.5 2.5
30 30
quantiteLessive = 2.5
nombreUtilisations = 30
main = do main = do
putStrLn "Calcul du coût des recettes\n" putStrLn "Calcul du coût des recettes\n"
putStrLn "* Lessive :" putStrLn "* Lessive :"
print lessive print lessive
putStrLn $ " * Prix Total = " ++ show (recipeCost lessive) ++ "" let lessiveTotalCost = recipeCost lessive
-- putStrLn $ " * Prix au litre = " ++ show prixLitre ++ "€" lessiveUnitCost = unitCost lessive lessiveTotalCost
-- putStrLn $ " * Prix par utilisation = " ++ show prixUtilisation ++ "€" lessiveUseCost = useCost lessive lessiveTotalCost
putStrLn $ " * Prix Total = " ++ show lessiveTotalCost ++ ""
putStrLn $ " * Prix au litre = " ++ show lessiveUnitCost ++ ""
putStrLn $ " * Prix par utilisation = " ++ show lessiveUseCost ++ ""

Loading…
Cancel
Save