Giter Club home page Giter Club logo

u1_lab_oop_exercise's Introduction

JS Object Oriented Programming

Getting Started

  • Fork and clone this repository
  • npm install in this directory

Overview

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.

Instructions

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

Step 1

In the School class:

  • set up a constructor that accepts schoolName and level 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 a student as a parameter.
  • create a method called listEnrollmentNumbers. This method will not accept any parameters.

Step 2

In the High class:

  • inherit from the School class:
    • Make sure to call super in the constructor.
  • Add a name parameter to the constructor.
  • Pass the name and hard code in a level in the super 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 of team

Step 3

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 the level parameter. (Order Matters)

Step 4

In the Primary class:

  • inherit from the School class
  • set up a constructor that accepts name and pickUpPolicy parameters
    • make sure to call super in the constructor
    • pass the name parameter to super and hard code a value for the level parameter. (Order Matters)
  • store the pickUpPolicy as a class property and set it to the pickUpPolicy argument
  • create a method called listPickUpPolicy

Step 5

In the Student class:

  • accept name and email as arguments in the constructor
  • store these as class properties

Step 6

Back in the School class:

  • The enrollStudent method should add a student to our students array.
  • listEnrollmentNumbers should return the number of students in our students array.

Step 7

Back in the High class:

  • the addTeam method should add a team to our sportsTeams array.

Step 8

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 <>!

Step 9

In the SportsTeam class:

  • set up a constructor with a name, sport and numOfPlayers property. These should be provided in the constructor arguments

Step 10

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 the Student class.
  • Add the 5 students to the students property in the instance of the High class. *We inherited from the School class which means we have access to the enrollStudent method.
  • Create 2 new sports teams. Add these to the instance of the High class you created utilzing the addTeam method.
  • console.log your instance of the High class.
  • Run the playground.js file with node playground.js in your terminal.

Additional Practice

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.

Resources

u1_lab_oop_exercise's People

Contributors

ben-manning avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.