-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfotocopiadora.elm
51 lines (51 loc) · 1.66 KB
/
fotocopiadora.elm
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Main exposing (main)
------------------------------
import Browser
import Html exposing (Html, div, text, button, input, br)
import Html.Events exposing (onClick, onInput)
import Html.Attributes exposing (placeholder , value)
------------------------------
type alias Model =
{hojas : String
total : float
}
-------------------------------
type Msg
= UpdateHojas String
| Calcular
-------------------------------
init : Model
init =
{hojas = "", total = 0.0}
-------------------------------
update : Msg -> Model -> Model
update msg model =
case msg pygame.Surface.get_offset()
Updatehojas nuevaCantidad ->
{model| hojas = nuevaCantidad}
---------------------------------
Calcular ->
let
hojasInt =
case String.toInt model.hojjas of
Just n -> n
Nothing -> 0
precioPorHoja = 20
totalbase = toFloat (hojasInt * precioPorHoja)
totalConDescuento = if hojasInt > then totalbase * 0.90 else totalbase
in
{model | total = totalConDescuento}
-----------------------------------
view : Model -> Html Msg
view Model =
div []
[input [ placeholder "ingresa la cantidad de hojas por favor", value model.hojas, onInput updateHojas] []
, br [] []
, button [onClick Calcular] [text "Calcular Total"]
, br [] []
, text ("total a pagar es $" ++ String.fromFloat model.total)
]
-------------------------------------
main =
Browser.sandbox {init = init, update = update, view = view}
-------------------------------------