Index
Video
Here is a video.. for this page.
Overview
This challenge is muscle memory style for learning how to code a class from scratch.
Objectives
This challenge covers:
- How to code a class from scratch
- Ivars, constructors, getters, setters, instance methods, and toString
- Running a .js file
- Debugging
- A big of logic
Problem Statement
Code up three JavaScript classes, each in a separate file. A guide example (full example) is provided.
Your classes may be anything you choose (Person, Planet, Car, Circle, Ellipse, etc). If you would like a more detail with a couple ideas go here...
For each class your code should include ("see <...>" applies to the "full example").
- One or more ivars
- One or more getters
- One or more setters
- Two or more instance methods
- One method named "toString" (see "toString")
- One or more logical instance methods (see "getShapeType" )
- One or more calc instance methods (see "getArea", and also "getFullName" for "Person" in section below).
- Print ten or more lines to the console (see "Try It Out")
Tips
- Do your quick run checks continuously as you go (much easier to debug ten lines of code vs 100)
- Keep it simple -- the full example is a bit lengthy by design, but your code can be much less
- Browse through the full full example first
- The example includes a copy icon under "Complete Source Code", if you want to use that code as a starting point (but it's a bit longer than what you need).
Quick Run Check
For this challenge, being it's an drill for muscle memory, we're not needing to do rigorous testing.
We just need to do a: quick run check...
For this challenge, we only need to be able to run the code all the way through without it being blocked by errors.
Scoring
See the "Quick Run Check" section above. If you get all the way through your program to the end (all prints) you are good.
The grader will not be checking any calcs you do -- this one is for coding syntax, not modeling precision.
The points are spread out evenly between the three classes.
Submitting
- Please only submit three .js files (otherwise the grader will not know which to look at). Other file types (.html, .css, etc are fine -- they will be ignored but will do no harm).
- Your three .js files may all be in one dir, or separate. Coder's choice.
- Please do not nest .zip files (do not put .zip files into the main .zip).
- Put your code into one .zip file as usual.
- Please name your zip file in the usual way ("Assignment XX -- FirstName LastName.zip" where "XX" is the assignment number and FirstName and LastName are your corresponding names in D2L).
References
JavaScript Guide
(Chapter 407 - Classes)