- Fork and clone this repository
npm install
in this directory
In this exercise, you will practice the principles object oriented programming to create a school system. There are 32 automated tests that you have to pass. You will also utilize the concept of inheritance
to create a blueprint for several schools. You should be running the tests after each step with npm test
.
You will be writing all of your code in the index.js
file. The class names have already been provided for you. You will be adding logic to the class definitions in this file
In the School
class:
- set up a constructor that accepts
schoolName
andlevel
parameters. - store these parameters in the constructor as class properties.
- set up a property called
students
and set it equal to an empty array. - create an
enrollStudent
method. It should accept astudent
as a parameter. - create a method called
listEnrollmentNumbers
. This method will not accept any parameters.
In the High
class:
- inherit from the
School
class:- Make sure to call
super
in the constructor.
- Make sure to call
- Add a
name
parameter to the constructor. - Pass the
name
and hard code in a level in thesuper
method. (Order matters, name should go first) - create a property called
sportsTeams
. Set this to an empty array. - create a method called
addTeam
, this should have a parameter ofteam
In the Middle
class:
- inherit from the
School
class - set up a constructor that accepts
name
as an argument - make sure to call
super
in the constructor - pass the
name
parameter to super and hard code value for thelevel
parameter. (Order Matters)
In the Primary
class:
- inherit from the
School
class - set up a constructor that accepts
name
andpickUpPolicy
parameters- make sure to call
super
in the constructor - pass the
name
parameter to super and hard code a value for thelevel
parameter. (Order Matters)
- make sure to call
- store the
pickUpPolicy
as a class property and set it to thepickUpPolicy
argument - create a method called
listPickUpPolicy
In the Student
class:
- accept
name
andemail
as arguments in the constructor - store these as class properties
Back in the School
class:
- The
enrollStudent
method should add astudent
to ourstudents
array. listEnrollmentNumbers
should return the number of students in ourstudents
array.
Back in the High
class:
- the
addTeam
method should add ateam
to oursportsTeams
array.
Back in the Primary
class:
listPickUpPolicy
should return the following string:You must pick up your child at <pickUpPolicy>!
. Make sure to replace the contents in<>
with your pickup policy property. Make sure to remove the<>
!
In the SportsTeam
class:
- set up a constructor with a
name
,sport
andnumOfPlayers
property. These should be provided in the constructor arguments
Once all 32 tests have passed, open the playground.js
file. Here you'll find:
const { High, Middle, Primary, SportsTeam, Student } = require('.')
The classes you've built have been loaded into this file for you. DO NOT MODIFY LINE 1.
- Create an instance of the
High
class. - Create
5
new students with theStudent
class. - Add the
5
students to thestudents
property in the instance of theHigh
class. *We inherited from theSchool
class which means we have access to theenrollStudent
method. - Create
2
new sports teams. Add these to the instance of theHigh
class you created utilzing theaddTeam
method. console.log
your instance of theHigh
class.- Run the
playground.js
file withnode playground.js
in your terminal.
Using the playground.js
file, create a few more instances of the Middle
, Primary
and Student
classes. Try mixing and matching which school the students are enrolled in.