Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngallagher committed Feb 4, 2019
1 parent 1ed526c commit 6a33a30
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Here you will get an overview on how the interpreter works and the language.
* [Evaluation](#evaluation)
* [Command Directive](#command-directive)
* [Example Programs](#example-programs)
* [Mario](#mario)
* [Flappy Bird](#flappy-bird)
* [Space Invaders](#space-invaders)
* [Tetris](#tetris)
* [Mario](#mario)
* [Flappy Bird](#flappy-bird)
* [Space Invaders](#space-invaders)
* [Tetris](#tetris)
* [Language](#language)
* [Basic Types](#basic-types)
* [Booleans](#booleans)
Expand Down Expand Up @@ -851,22 +851,53 @@ A class is the most basic type. It contains variables and functions that can ope
Once declared a type can be instantiated by calling a special function called a constructor.
```js
class ImageCache<K, V: Image> {
let map = new HashMap<?, V>();
abstract class Shape {
public cache(k: K, v: V) {
map.put(k, v);
let origin: Point;
new(origin: Point) {
this.origin = origin;
}
/**
* Draw the shape to the provided graphics. Each
* shape will be drawn from the origin.
*
* @param g the graphics to draw with
*/
abstract draw(g: Graphics);
public fetch(k: K): V {
return map.get(k);
class Point { // inner class
const x;
const y;
new(x, y) {
this.x = x;
this.y = y;
}
}
}
}
class Square extends Shape {
let cache = new ImageCache<String, BufferedImage>();
private let width: Integer;
private let height: Integer;
cache.cache('logo.png', logo);
new(origin: Point, width: Integer, height: Integer): super(origin) {
this.width = width;
this.height = height;
}
/**
* Draw a square at the origin.
*
* @param g the graphics to draw on
*/
override draw(g: Graphics) {
g.drawSquare(origin.x, origin.y, width, height);
}
}
```
#### Enumeration
Expand Down

0 comments on commit 6a33a30

Please sign in to comment.