Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
8
Task/Abstract-type/F-Sharp/abstract-type-1.fs
Normal file
8
Task/Abstract-type/F-Sharp/abstract-type-1.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
type Shape =
|
||||
abstract Perimeter: unit -> float
|
||||
abstract Area: unit -> float
|
||||
|
||||
type Rectangle(width, height) =
|
||||
interface Shape with
|
||||
member x.Perimeter() = 2.0 * width + 2.0 * height
|
||||
member x.Area() = width * height
|
||||
16
Task/Abstract-type/F-Sharp/abstract-type-2.fs
Normal file
16
Task/Abstract-type/F-Sharp/abstract-type-2.fs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[<AbstractClass>]
|
||||
type Bird() =
|
||||
// an abstract (=virtual) method with default impl.
|
||||
abstract Move : unit -> unit
|
||||
default x.Move() = printfn "flying"
|
||||
// a pure virtual method
|
||||
abstract Sing: unit -> string
|
||||
|
||||
type Blackbird() =
|
||||
inherit Bird()
|
||||
override x.Sing() = "tra-la-la"
|
||||
|
||||
type Ostrich() =
|
||||
inherit Bird()
|
||||
override x.Move() = printfn "walking"
|
||||
override x.Sing() = "hiss hiss!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue