diff --git a/index.js b/index.js index fc39606fe..71a1af1f6 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(edible) { + if(this.stomach.length < 10){ + this.stomach.push(edible); + } + } + poop() { + this.stomach = []; + } + toString() { + return`${this.name}, ${this.age}` + } } /* @@ -62,9 +77,27 @@ class Person { */ class Car { - + constructor(model, mpg) { + this.model = model; + this.milesPerGallon = mpg; + this.tank = 0; + this.odometer = 0; + } + fill(gallons) { + this.tank = this.tank + gallons; + } + drive(distance) { + const drivableMiles = this.tank * this.milesPerGallon + if(distance <= drivableMiles){ + this.odometer = this.odometer + distance; + this.tank = this.tank - (distance / this.milesPerGallon); + } else { + this.odometer = this.odometer + drivableMiles; + this.tank = 0; + return `I ran out of fuel at ${this.odometer} miles!` + } +} } - /* TASK 3 - Write a Lambdasian class. @@ -79,9 +112,15 @@ class Car { */ class Lambdasian { - + constructor({name, age, location}){ + this.name = name; + this.age = age; + this.location = location; +} +speak() { + return `Hello my name is ${this.name}, I am from ${this.location}.` +} } - /* TASK 4 - Write an Instructor class extending Lambdasian. @@ -97,8 +136,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({name, age, location, specialty, favLanguage, catchPhrase}) { + super({name, age, location, specialty, favLanguage, catchPhrase}); + this.specialty = specialty; + this.favLanguage = favLanguage; + this.catchPhrase = catchPhrase; + } + demo(subject) { + return `Today we are learning about ${subject}` + } + grade(student, subject) { + return `${student.name} receives a perfect score on ${subject}` + } } /* @@ -117,8 +167,22 @@ class Instructor { + `sprintChallenge` similar to PRAssignment but returns `student.name has begun sprint challenge on {subject}` */ -class Student { - +class Student extends Lambdasian{ + constructor ({name, age, location, previousBackground, className, favSubjects}) { + super ({name, age, location, previousBackground, className, favSubjects}); + this.previousBackground = previousBackground; + this.className = className; + this.favSubjects = favSubjects; + } + listSubjects() { + return `Loving ${this.favSubjects}` + } + PRAssignment(subject) { + return `${this.name} has submitted a PR for ${subject}` + } + sprintChallenge(subject) { + return `${this.name} has begun spring challenge on ${subject}` + } } /* @@ -135,9 +199,21 @@ 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({name, age, location, specialty, favLanguage, catchPhrase, gradClassName, favInstructor}) { + super({name, age, location, specialty, favLanguage, catchPhrase, gradClassName, favInstructor}); + this.gradClassName = gradClassName; + this.favInstructor = 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}`; + } + } + + /* STRETCH PROBLEM (no tests!)