Skip to content

A3 - Creating Basic Classes

In this assignment, we're going to take a look at designing classes from the ground up.

Run the update, then look for a new a3 folder inside Unit 4. Start by exploring inside the sample subfolder. Run index.html using Live Server, and read through index.js. The sample contains a full example with lots of commenting to explain it through.

Once you're comfortable with how the sample works, work with the files inside the root of the a3 folder similarly. This time, index.js is bare bones. You will modify it as per the task below.

Your Task

Modify the class you were given so it represents something useful. It should contain.

  • A constructor that accepts some information about the object
  • A method that will print out the information about the object
  • A method that will allow the information about the object to be changed

For example, you could make a Car class that:

  • Has a constructor that accepts as arguments the make, model and colour
  • Has a method that will print the make model and colour
  • Has a method that method that will allow one or more of these attributes to be changed