Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Classes/F-Sharp/classes-1.fs
Normal file
9
Task/Classes/F-Sharp/classes-1.fs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
type MyClass(init) = // constructor with one argument: init
|
||||
let mutable var = init // a private instance variable
|
||||
member x.Method() = // a simple method
|
||||
var <- var + 1
|
||||
printfn "%d" var
|
||||
|
||||
// create an instance and use it
|
||||
let myObject = new MyClass(42)
|
||||
myObject.Method()
|
||||
15
Task/Classes/F-Sharp/classes-2.fs
Normal file
15
Task/Classes/F-Sharp/classes-2.fs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
open System
|
||||
|
||||
type Shape =
|
||||
abstract Perimeter: unit -> float
|
||||
abstract Area: unit -> float
|
||||
|
||||
type Circle(radius) =
|
||||
interface Shape with
|
||||
member x.Perimeter() = 2.0 * radius * Math.PI
|
||||
member x.Area() = Math.PI * radius**2.0
|
||||
|
||||
type Rectangle(width, height) =
|
||||
interface Shape with
|
||||
member x.Perimeter() = 2.0 * width + 2.0 * height
|
||||
member x.Area() = width * height
|
||||
Loading…
Add table
Add a link
Reference in a new issue