From 291507b4ca236bb62e52ce7e17615a4eb35f924d Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 12:48:11 -0500 Subject: [PATCH 1/7] implemented Person class --- index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0df18af74..ad550f63b 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,21 @@ class Airplane { */ class Person { - + constructor(name, age){ + this.name = name; + this.age = age; + this.stomach = []; + } + eat(someFood){ + if (this.stomach.length < 10) + this.stomach.push(someFood); + } + poop(){ + this.stomach.length = 0; + } + toString(){ + return `${this.name}, ${this.age}`; + } } /* From f89bc6c0d8fc02ed15b8da00363a5d7a38a62610 Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 13:10:41 -0500 Subject: [PATCH 2/7] implemented Car class --- index.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ad550f63b..675e01424 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,27 @@ 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 (distance > maxDistance){ + this.odometer += maxDistance; + this.tank = 0; + return `I ran out of fuel at ${this.odometer} miles!`; + } + else { + this.odometer += distance; + this.tank -= distance / this.milesPerGallon; + } + } } /* From 32b17bad10756331b198f21d075fbbe191e0f898 Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 13:41:01 -0500 Subject: [PATCH 3/7] implemented Lambdasian class --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 675e01424..119a933a6 100644 --- a/index.js +++ b/index.js @@ -109,6 +109,14 @@ class Car { + {name} and {location} of course come from the instance's own properties. */ class Lambdasian { + constructor(props){ + this.name = props.name; + this.age = props.age; + this.location = props.location; + } + speak(){ + return `Hello my name is ${this.name}, I am from ${this.location}`; + } } From 8d67e983321612465a31859808d40566724eb76c Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 13:41:40 -0500 Subject: [PATCH 4/7] implemented Instructor class --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 119a933a6..e6dee5c1d 100644 --- a/index.js +++ b/index.js @@ -134,8 +134,19 @@ class Lambdasian { + `demo` receives a `subject` string as an argument and returns the phrase 'Today we are learning about {subject}' where subject is the param passed in. + `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(props){ + super(props); + this.specialty = props.specialty; + this.favLanguage = props.favLanguage; + this.catchPhrase = props.catchPhrase; + } + demo(subject){ + return `Today we are learning about ${subject}`; + } + grade(student, subject){ + return `${student.name} receives a perfect score on ${subject}`; + } } /* From 2585f09e7e943709ac7ea1d29c4b78a6bc6ccc8f Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 14:17:24 -0500 Subject: [PATCH 5/7] implemented Student class --- index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e6dee5c1d..737d33b68 100644 --- a/index.js +++ b/index.js @@ -164,8 +164,22 @@ class Instructor extends Lambdasian { + `PRAssignment` a method that receives a subject as an argument and returns `student.name has submitted a PR for {subject}` + `sprintChallenge` similar to PRAssignment but returns `student.name has begun sprint challenge on {subject}` */ -class Student { - +class Student extends Lambdasian { + constructor(props){ + super(props); + this.previousBackground = props.previousBackground; + this.className = props.className; + this.favSubjects = props.favSubjects; + } + listSubjects(){ + return this.favSubjects.join(', ') + '!'; + } + PRAssignment(subject){ + return `${this.name} has submitted a PR for ${subject}`; + } + sprintChallenge(subject){ + return `${this.name} has begun sprint challenge on ${subject}`; + } } /* From 273474dbee402725d09c6bc7eb412b0329771623 Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 14:22:08 -0500 Subject: [PATCH 6/7] implemented ProjectManager class --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 737d33b68..6b91bbec6 100644 --- a/index.js +++ b/index.js @@ -195,8 +195,18 @@ class Student extends Lambdasian { + `standUp` a method that takes in a slack channel and returns `{name} announces to {channel}, @channel standy times!` + `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(props){ + super(props); + this.gradClassName = props.gradClassName; + this.favInstructor = props.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}`; + } } /* From 0f513743b43a5d71dc9b39cd1342746f459804dd Mon Sep 17 00:00:00 2001 From: Anthony K Date: Thu, 27 Feb 2020 14:45:28 -0500 Subject: [PATCH 7/7] implemented STRETCH - new functionality to Student and Instructor --- index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.js b/index.js index 6b91bbec6..54788b711 100644 --- a/index.js +++ b/index.js @@ -145,6 +145,17 @@ class Instructor extends Lambdasian { return `Today we are learning about ${subject}`; } grade(student, subject){ + // STRETCH + if (!student.hasGraduated) { + let rand = Math.random() * 100; + let positive = (Math.random() > 0.5) ? true : false; + student.grade = positive ? student.grade += rand : student.grade -= rand; + if (student.grade > 100) student.grade = 100; + if (student.grade < 1) student.grade = 1; + } + else + return `${student.name} has graduated and doesn't need any more grading!`; + return `${student.name} receives a perfect score on ${subject}`; } } @@ -170,6 +181,8 @@ class Student extends Lambdasian { this.previousBackground = props.previousBackground; this.className = props.className; this.favSubjects = props.favSubjects; + this.grade = Math.random() * 100 + 1; + this.hasGraduated = false; } listSubjects(){ return this.favSubjects.join(', ') + '!'; @@ -180,6 +193,15 @@ class Student extends Lambdasian { sprintChallenge(subject){ return `${this.name} has begun sprint challenge on ${subject}`; } + graduate(){ + if (!this.hasGraduated) + if (this.grade > 70) + this.hasGraduated = true; + else + return `${this.name} needs higher grades!`; + else + return `${this.name} has already graduated!`; + } } /* @@ -218,6 +240,7 @@ class ProjectManager extends Instructor { + If the student's grade is above a 70% let them graduate! Otherwise go back to grading their assignments to increase their score. */ + ///////// END OF CHALLENGE ///////// ///////// END OF CHALLENGE ///////// ///////// END OF CHALLENGE /////////