From bf663bde67e682cf5a66dc3c2ed058ae36c9de05 Mon Sep 17 00:00:00 2001 From: Jomar Banting Date: Fri, 20 Jan 2023 01:09:45 -0500 Subject: [PATCH] Answered all the question including the STRETCH problem --- index.js | 107 ++++++++++++++++++++++++++++++++++++++++++---- package-lock.json | 4 +- 2 files changed, 101 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index fc39606fe..549369521 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,23 @@ class Airplane { */ class Person { - + constructor(name, age){ + this.stomach = []; + this.name = name; + this.age = age; + } + eat(someFood) { + if(this.stomach.length < 10) + { + this.stomach.push(someFood); + } + } + poop() { + this.stomach = []; + } + toString(){ + return `${this.name}, ${this.age}`; + } } /* @@ -62,7 +78,26 @@ class Person { */ class Car { - + constructor(model, milesPerGallon) { + this.model = model; + this.milesPerGallon = milesPerGallon; + this.tank = 0; + this.odometer = 0; + } + fill(gallons){ + this.tank += gallons; + } + drive(distance){ + let maxDistance = this.tank * this.milesPerGallon; + if (maxDistance > distance){ + this.odometer += distance; + this.tank = this.tank - (distance / this.milesPerGallon).toFixed(2); + } else { + this.odometer += maxDistance; + this.tank = 0; + return `I ran out of fuel at ${this.odometer} miles!`; + } + } } /* @@ -79,7 +114,14 @@ class Car { */ class Lambdasian { - + constructor(arg){ + this.name = arg.name; + this.age = arg.age; + this.location = arg.location; + } + speak(){ + return `Hello my name is ${this.name}, I am from ${this.location}`; + } } /* @@ -97,7 +139,23 @@ 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(arg){ + super(arg); + this.specialty = arg.specialty; + this.favLanguage = arg.favLanguage; + this.catchPhrase = arg.catchPhrase; + } + demo(subject){ + return `Today we are learning about ${subject}` + } + grade(student, subject){ + return `${student.name} receives a perfect score on ${subject}`; + } + randomGrade(grade){ + let randomNumber = Math.floor(Math.random() * (10 - (-10)) + (-10)); + return grade += randomNumber; + } } @@ -117,8 +175,31 @@ class Instructor { + `sprintChallenge` similar to PRAssignment but returns `student.name has begun sprint challenge on {subject}` */ -class Student { - +class Student extends Lambdasian{ + constructor(arg){ + super(arg); + this.previousBackground = arg.previousBackground; + this.className = arg.className; + this.favSubjects = arg.favSubjects; + this.grade = arg.grade; + } + 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}`; + } + graduate(){ + if (this.grade > 70) + { + return `You are ready to graduate!`; + } else { + return `You still need to increase your grade in order to graduate!`; + } + } } /* @@ -135,8 +216,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(arg){ + super(arg); + this.gradClassName = arg.gradClassName; + this.favInstructor = arg.favInstructor; + } + standUp(channel){ + return `${this.name} announces to ${channel}, @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",