/shapes_javascript_inheritance

Practice inheritance by creating different shapes with javascript

Primary LanguageJavaScript

Shapes!

The goal of this assignment is to understand inheritance in javascript.

Steps

  1. Look at the source files for shape.js, square.js, rectangle.js. The shape.js file will have all the functions that need to be implemented. Do not write code yet!
  2. Write your tests first. Implement tests for shape, square and rectangle.
  3. Once your tests are written, start implementing the functions in shape, square and rectangle.
    • Square and rectangle should inherit from shape.
    • The getRGB function should only be written once.

Bonus

  • Implement an equilateral triangle object. Have it inherit from shape as well.
  • When you implement draw, try to figure out how to print the shape to the screen including color. You can change the color of a symbol like * and fill the entire shape with those symbols. For example
-------
|* * *|
|* * *|
|* * *|
-------

The * should be in the color of the shape!