Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- //Приведите примеры классов заданные явным и неявным образом
- //(не менее четырех полей, двух конструкторов и трех методов).
- //Продемонстрируйте работу с ними.
- type Room =
- val mutable qual: string
- val number: int
- val mutable beds: int
- val windows: int
- val mutable reserved: bool
- new(q:string, n, b, w, r: bool) = { qual = q; number = n; beds = b; windows = w; reserved=r;}
- //Констурктор без параметров
- new() = {qual = ""; number = 0; beds = 0; windows = 0; reserved = false}
- member this.Reservation()=
- printfn "This room is reserved"
- this.reserved <- true
- member this.MoveOut() =
- printfn "This room is free"
- this.reserved <- false
- member this.AddBeds() =
- printfn "This room is added bed"
- this.beds <- this.beds+1
- let n_402 = Room("VIP", 402, 2, 1, false)
- printfn "%A" n_402.number
- n_402.Reservation()
- printfn "%b" n_402.reserved
- n_402.MoveOut()
- printfn "%b" n_402.reserved
- n_402.AddBeds()
- printfn "%A" n_402.beds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement