Stenway Developer Network

Classes

There are three types of classes: instance, static and abstract classes. Static and abstract classes cannot be instantiated.

package MyLib

class MyInstanceClass

end

static class MyStaticClass

end

abstract class MyAbstractClass

end

The access modifier always goes before the class type keyword

package MyLib

internal static class MyInternalStaticClass

end

Inheritance

With the extends keyword you can inherit from a single base class.

package MyLib

class MyClass extends BaseClass

end

class BaseClass

end

A class can implement multiple interfaces using the implements keyword.

package MyLib

class MyClass extends BaseClass implements IInterface1, IInterface2

end

class BaseClass

end

interface IInterface1

end

interface IInterface2

end

Properties

package MyLib

class Vector2D
  x float
  y float
end

Constructors

A class can have only one constructor.

package MyLib

class Vector2D
  x float
  y float

  constructor(x float, y float)
    this.x = x
    this.y = y
  end
end

Methods

package MyLib

using System

class Vector2D
  x float
  y float

  constructor(x float, y float)
    this.x = x
    this.y = y
  end

  getLength() float
    return Math.sqrt(this.x * this.x + this.y * this.y)
  end
end

Colon Notation

A block can be shortend to:

package MyLib

using System

class Vector2D
  x float
  y float

  constructor(x float, y float)
    this.x = x
    this.y = y
  end

  getLength() float : return Math.sqrt(this.x * this.x + this.y * this.y)
end