1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15class Shape {
16  constructor (id,x,y) {
17    this.id = id;
18    this.x = x;
19    this.y = y;
20  }
21  toString () {
22      return "Shape(" + this.id + ")"
23  }
24}
25class Rectangle extends Shape {
26  constructor (id, x, y, width, height) {
27      super (id, x, y);
28  }
29  toString () {
30      return "Rectangle > " + super.toString ();
31  }
32}
33class Circle extends Shape {
34  constructor (id, x, y, radius) {
35      super (id, x, y);
36  }
37  toString () {
38      return "Circle > " + super.toString ();
39  }
40}
41var shape = new Shape (0, 0, 0);
42var rec = new Rectangle (1, 0, 0, 4, 4);
43var circ = new Circle (2, 0, 0, 4);
44
45assert (Object.keys (shape).toString () === "id,x,y");
46assert (rec.id === 1);
47assert (circ.id === 2);
48assert (rec.toString () === "Rectangle > Shape(1)");
49assert (circ.toString () === "Circle > Shape(2)");
50