Skip to content

Arthur Bates #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
108 changes: 108 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,109 @@
// CODE here for your Lambda Classes
class Person {
constructor(attrs) {
this.name = attrs.name;
this.age = attrs.age;
this.gender = attrs.gender;
this.location = attrs.location;
}
speak() {
return `Hello, my name is ${this.name}, I am from ${this.location}`;
}
}

class Instructor extends Person {
constructor(instrAttrs) {
super(instrAttrs);
this.specialty = instrAttrs.specialty;
this.favLanguage = instrAttrs.favLanguage;
this.catchPhrase = instrAttrs.catchPhrase;
}
demo(subject) {
return `Today we are learning about ${subject}`;
}

grade(Student, subject) {
return `${Student.name} receives a perfect score on ${subject}`;
}
curve(grade) {
return Math.random() + grade;
}
}

class Student extends Person {
constructor(StudentAttrs) {
super(StudentAttrs);
this.previousBackground = StudentAttrs.previousBackground;
this.className = StudentAttrs.className;
this.favSubjects = StudentAttrs.favSubjects;
this.grade = StudentAttrs.grade;
}
listsSubjects() {
return `My favorite subjects are ${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 `${this.name} has graduated!`;
}
}
}

class ProjectManager extends Instructor {
constructor(PMAttrs) {
super(PMAttrs);
this.gradClassName = PMAttrs.gradClassName;
this.favInstructor = PMAttrs.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}`;
}
}

const Arthur = new Student({
name: 'Arthur',
location: 'Greensboro',
previousBackground: 'Graphic Design',
className: 'CS12',
favSubjects: ['JavaScript', ' Python', ' MySQL', ' React'],
grade: 90

});

const Josh = new Instructor({
specialty: ['teaching', 'coding'],
favLanguage: ['C++', 'Python', 'redux'],
catchPhrase: "Don't forget the homies"
});

const Nathan = new ProjectManager({
name: 'Nathan',
gradClassName: 'CS7',
favInstructor: 'Josh',

});

console.log(Arthur.previousBackground);
console.log(Arthur.listsSubjects());
console.log(Arthur.PRAssignment('mySQL'));
console.log(Arthur.sprintChallenge('JavaScript'));
console.log(Arthur.graduate());
console.log(Josh.specialty);
console.log(Josh.catchPhrase);
console.log(Josh.demo('Python'));
console.log(Josh.curve(99));
console.log(Nathan.gradClassName);
console.log(Nathan.debugsCode(Arthur, 'Javascript'));
console.log(Arthur.speak());
console.log(Nathan.standUp('CS12'));
console.log(Josh.grade(Arthur, 'JavaScript'));
56 changes: 28 additions & 28 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
// Today your goal is to refactor all of this code to use ES6 Classes.
// The console.log() statements should still return what is expected of them.

function GameObject(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}

GameObject.prototype.destroy = function() {
return `Object was removed from the game.`;
};

function CharacterStats(characterStatsOptions) {
GameObject.call(this, characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
class GameObject {
constructor(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}
destroy() {
return `Object was removed from the game.`;
}
}

CharacterStats.prototype = Object.create(GameObject.prototype);

CharacterStats.prototype.takeDamage = function() {
return `${this.name} took damage.`;
};

function Humanoid(humanoidOptions) {
CharacterStats.call(this, humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
class CharacterStats extends GameObject {
constructor(characterStatsOptions) {
super(characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;
}
takeDamage() {
return `${this.name} took damage.`;
}
}

Humanoid.prototype = Object.create(CharacterStats.prototype);

Humanoid.prototype.greet = function() {
return `${this.name} offers a greeting in ${this.language}.`;
};
class Humanoid extends CharacterStats {
constructor(humanoidOptions) {
super(humanoidOptions);
this.faction = humanoidOptions.faction;
this.weapons = humanoidOptions.weapons;
this.language = humanoidOptions.language;
}
greet() {
return `${this.name} offers a greeting in ${this.language}.`;
}
}

const mage = new Humanoid({
createdAt: new Date(),
Expand Down