nondev/spoon

View on GitHub
examples/classes.spoon

Summary

Maintainability
Test Coverage
#!/usr/bin/env coffee

class Point2d
  new = (x : Int, y : Int) : Void =>
    @x : Int = x
    @y : Int = y

  to-string = : String ->
    "Point2d: x=#{@x}, y=#{@y}"

class Point3d extends Point2d
  new = (x : Int, y : Int, z : Int) : Void =>
    super x, y
    @z : Int = z

  \override
  to-string = : String ->
    "Point3d: x=#{@x}, y=#{@y}, z=#{@z}"

point2d = Point2d(100, 200)
trace point2d.to-string!

point3d = Point3d(100, 200, 150)
trace point3d.to-string!