From a123c95f53f2479178d79f77e44b2425264a7eb9 Mon Sep 17 00:00:00 2001 From: Terri Archer Date: Sat, 3 Sep 2022 12:25:13 -0400 Subject: [PATCH] completed coursework --- index.js | 94 +++++++++++++++++++++++++++++++++++++++++++---- package-lock.json | 4 +- 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index fc39606fe..f4a375373 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,22 @@ class Airplane { */ class Person { - + constructor(name,age){ + this.name = name; + this.age = age; + this.stomach = []; + } + eat(food) { + if(this.stomach.length <= 9){ + this.stomach.push(food) + } + } + poop() { + this.stomach.length = 0 + } + toString() { + return `${this.name}, ${this.age}` + } } /* @@ -62,7 +77,27 @@ class Person { */ class Car { - + constructor(model,milesPerGallon) { + this.model = model; + this.milesPerGallon = milesPerGallon + this.tank = 0 + this.odometer = 0 + } + fill(gallons) { + this.tank = this.tank + gallons + } + drive (distance) { + const milesDrive = this.tank * this.milesPerGallon; + if(distance <= milesDrive){ + this.odometer = this.odometer + distance; + this.tank = this.tank - (distance / this.milesPerGallon) + } + else{ + this.odometer = this.odometer + milesDrive; + this.tank = 0; + return `I ran out of fuel at ${this.odometer} miles!` + } + } } /* @@ -79,7 +114,14 @@ class Car { */ class Lambdasian { - + constructor(attrs) { + this.name = attrs.name + this.age = attrs.age + this.location = attrs.location + } + speak() { + return `Hello my name is ${this.name}, I am from ${this.location}` + } } /* @@ -97,8 +139,19 @@ class Lambdasian { + `grade` receives a `student` object and a `subject` string as arguments and returns '{student.name} receives a perfect score on {subject}' */ -class Instructor { - +class Instructor extends Lambdasian{ + constructor(attrs) { + super(attrs) + this.specialty = attrs.specialty; + this.favLanguage = attrs.favLanguage; + this.catchPhrase = attrs.catchPhrase + } + demo(subject){ + return `Today we are learning about ${subject}` + } + grade(student,subject){ + return `${student.name} receives a perfect score on ${subject}` + } } /* @@ -117,8 +170,22 @@ class Instructor { + `sprintChallenge` similar to PRAssignment but returns `student.name has begun sprint challenge on {subject}` */ -class Student { - +class Student extends Lambdasian { + constructor(attrs){ + super(attrs) + this.previousBackground = attrs.previousBackground; + this.className = attrs.className; + this.favSubjects = attrs.favSubjects + } + listSubjects () { + return 'Loving '+ this.favSubjects + '!' + } + PRAssignment(subject){ + return `${this.name} has submitted a PR for ${subject}` + } + sprintChallenge(subject){ + return `${this.name} has begun sprint challenge on ${subject}` + } } /* @@ -135,7 +202,18 @@ class Student { + `debugsCode` a method that takes in a student object and a subject and returns `{name} debugs {student.name}'s code on {subject}` */ -class ProjectManager { +class ProjectManager extends Instructor{ + constructor(attrs){ + super(attrs) + this.gradClassName = attrs.gradClassName + this.favInstructor = attrs.favInstructor + } + standUp(slack){ + return `${this.name} announces to ${slack}, @channel standy times!` + } + debugsCode(student,subject) { + return `${this.name} debugs ${student.name}'s code on ${subject}` + } } diff --git a/package-lock.json b/package-lock.json index 3e3866147..4a96a12c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codegraded-project-js", - "version": "0.0.7", + "version": "0.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codegraded-project-js", - "version": "0.0.7", + "version": "0.0.9", "devDependencies": { "@babel/core": "7.17.8", "@babel/plugin-transform-runtime": "7.17.0",