Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 107 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
}

/*
Expand All @@ -59,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;
}
}
}

/*
Expand All @@ -75,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}`;
}

}

Expand All @@ -92,8 +134,30 @@ 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){
// 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}`;
}
}

/*
Expand All @@ -111,8 +175,33 @@ class Instructor {
+ `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;
this.grade = Math.random() * 100 + 1;
this.hasGraduated = false;
}
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}`;
}
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!`;
}
}

/*
Expand All @@ -128,8 +217,18 @@ class Student {
+ `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}`;
}
}

/*
Expand All @@ -141,6 +240,7 @@ class ProjectManager {
+ 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 /////////
Expand Down