GithubHelp home page GithubHelp logo

classes-hw-js's Introduction

Classes-HW-JS

Making Classes

  1. Create a class for a Pet

    • attributes
      • name (the constructor takes one parameter and then sets this property on the instance to value of the parameter)
      • owner (initially set to '' within constructor)
    • methods
      • setOwner(owner) - sets the owner property to the parameter passed into this function

    Commit 1


    ๐Ÿ”ด The commit message should read:
    "Commit 1 - Created Pet Class"
  2. Create a class for a Dog

    • this should inherit the attributes from Pet
    • attributes
      • price (the constructor takes a parameter in addition to that of Pet and then sets this property on the instance to the value of the additional parameter)
    • methods
      • bark() - log "bark"
      • chaseTail() - log "oh boy oh boy oh boy"
      • getPrice() - return price
  3. Create an instance of Dog called "Sparky" and set add all the details that need to be added to make a "complete" Dog. Run the methods to ensure that everything works.

    Commit 2


    ๐Ÿ”ด The commit message should read:
    "Commit 2 - Created Dog Class"
  4. Create a class for a Cat

    • this should inherit from Pet
    • attributes
      • price (the constructor takes a parameter in addition to that of Pet and then sets this property on the instance to the value of the additional parameter)
    • methods
      • purr() - log "purrrrr"
      • clean() - log "cleaning"
      • getPrice() - return price
  5. Create an instance of Cat called "Sprinkles" and set add all the details that need to be added to make a "complete" Cat. Run the methods to ensure that everything works.

    Commit 3


    ๐Ÿ”ด The commit message should read:
    "Commit 3 - Created Cat Class"
  6. Create a class for a Person

    • attributes
      • name - set name from parameter in constructor method
      • age - initially 0
      • weight - initially 0
      • mood - integer starting at 0 initially
      • pets - empty array initially
      • bankAccount - initially set to 0
    • methods
      • getName() - returns the name of the person
      • getAge() - returns age
      • getWeight() - returns weight
      • greet(other_person) - logs a message with another person's name
      • eat() - increment weight, increment mood
      • exercise() - decrement weight
      • age() - increment age, increment weight, decrement mood, increment bank account by 10 (birthday money)
      • buyPet(pet) - push the pet object onto the pets array, increment mood by 10, decrement bankAccount by the value of the pet (hint: getPrice())
  7. Create an instance of Person called "Jill" and set add all the details that need to be added to make a "complete" Person. Run the methods to ensure that everything works.

    Commit 4


    ๐Ÿ”ด The commit message should read:
    "Commit 4 - Created Person Class"

Hungry for more?

Factories

  1. Create a single factory object to generate shoes

    • The factory should have an array of shoes that it has generated
    • A shoe should have a serial number, based on what index it is in the factory's shoes array
  2. Create Malls & Stores

    • Create a Store class. It should have a constructor method that is called when a new store is created. It will take, as parameters, mallName and serialNumber.
    • Create a Mall class. A Mall should have a constructor method that is called when a new mall is created. It takes the mallName as a parameter ("Mall of America", "Tanger Outlets", etc.).
    • The Mall should have a generateStore method that creates instances of class Store. When creating an instance of class Store, it passes in its mallName as the mallName parameter to Store.
    • The Mall should keep track of how many stores are created; passing in this number as the serialNumber to the store.
    • Create a couple of instances of a Store to verify that it's working.

Commit 7


๐Ÿ”ด The commit message should read:
"Commit 7 - Factories"

classes-hw-js's People

Contributors

jimbojones1 avatar

Watchers

James Cloos 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.