Skip to content
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

Brendan schatz #676

Open
wants to merge 3 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
132 changes: 132 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,133 @@
// CODE here for your Lambda Classes

class PersonClass {
constructor(attributes) {
this.name = attributes.name,
this.age = attributes.age,
this.location = attributes.location
};
speak() {
return `Hello my name is ${this.name}, I am from ${this.location}`
};
};

class Instructor extends PersonClass {
constructor(prefs) {
super(prefs),
this.specialty = prefs.specialty,
this.favLanguage = prefs.favLanguage,
this.catchPhrase = prefs.catchPhrase
};
demo(subject) {
return `Today we are learning about ${subject} where subject is the param passed in`
};
grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}`
};
assignScore() {
return Math.floor(Math.random() * Math.floor(100));
}
}


class Student extends PersonClass {
constructor(knowledge) {
super(knowledge),
this.previousBackground = knowledge.previousBackground,
this.className = knowledge.className,
this.favSubjects = knowledge.favSubjects,
this.grade = knowledge.grade
};
listsSubjects() {
return `${this.name}'s 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() {
this.grade = Math.floor(Math.random() * Math.floor(100));

if (this.grade > 70) {
return `Congratulations you graduate Lambda with a ${this.grade}%`
}
else {
return `Sorry you failed to graduate because ${this.grade}% is not passing`
}
}

}

class ProjectManager extends Instructor {
constructor(specialty) {
super(specialty),
this.gradClassName = specialty.gradClassName,
this.favInstructor = specialty.favInstructor
}
standUp(slackChannel) {
return `${this.name} announces to ${slackChannel} @channel standy times!`
}
debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}`
}
}

const fred = new Instructor({
name: 'Fred',
location: 'Bedrock',
age: 37,
favLanguage: 'JavaScript',
specialty: 'Front-end',
catchPhrase: `Don't forget the homies`
});

const ObiWan = new Instructor({
name: 'Obi Wan',
location: 'Tatooin',
age: 84,
favLanguage: 'Condecending',
specialty: 'Training Sith Lords',
catchPhrase: `I have the high ground`
});

const Yoda = new ProjectManager({
name: 'Yoda',
location: 'Afterlife',
age: 637,
favLanguage: 'Metaphors',
specialty: 'The force',
catchPhrase: `Do or do not. There is no try.`,
gradClassName: 'Too long ago to remember',
favInstructor: 'Mace Windu was my BOI'
});

const Emporer = new ProjectManager({
name: 'Palpaltine',
location: 'The Heart of a volcano',
age: 137,
favLanguage: 'Cackling',
specialty: 'The Dark Side',
catchPhrase: `Do It!!!!`,
gradClassName: 'Darth Plagus',
favInstructor: 'Myself HAHAHAHA'
});

const Luke = new Student({
name: 'Luke',
location: 'Who Cares?',
age: 70,
previousBackground: "Building sand castles",
className: 'Yodas school for the gifted',
favSubjects: ['Running through trees', 'Flipping over rocks', 'Carrying Yoda like a baby'],
grade: 80
});

console.log(Luke);
console.log(Emporer.standUp("SithLords"))
console.log(ObiWan.speak())


console.log(Yoda.assignScore())
console.log(Luke.graduate());
170 changes: 170 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict"
/*

Prototype Refactor
Expand All @@ -7,3 +8,172 @@ Prototype Refactor
2. 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.

*/

class GameObject{
constructor(attributes) {
this.createdAt = attributes.createdAt,
this.name = attributes.name,
this.dimensions = attributes.dimensions
};
destroy() {
return `${this.name} was removed from the game`;
}
}


class CharacterStats extends GameObject {
constructor(stats) {
super(stats);
this.healthPoints = stats.healthPoints;
this.attackPoints = stats.attackPoints;
}
takeDamage() {
return `${this.name} took ${this.attackPoints} damage`;
}
}


class Humanoid extends CharacterStats {
constructor(args) {
super(args);
this.team = args.team;
this.weapons = args.weapons;
this.language = args.language;
};

greet() {
return `${this.name} offers a greeting in ${this.language}`;
}

getHit(attacker) {
this.healthPoints = this.healthPoints - attacker.attackPoints;
if (this.healthPoints > 0) {
return `${this.name} took ${attacker.attackPoints} points of damage he now has ${this.healthPoints} health left`
}
else {
return `${this.name} took ${attacker.attackPoints} points of damage he now has ${this.healthPoints} and is dead`
}
}

attack(opponent) {
return `${this.name} uses his ${this.weapons} to attack ${opponent.name} for ${this.attackPoints}`
}
}


class EvilCharacter extends Humanoid {
constructor(args) {
super(args);
}
attack() {
return `${this.name} uses his ${this.weapons[0]} to attack ${mage.name} for ${this.attackPoints}`
}

threaten() {
return `I ${this.name} will destroy you!!!`
}
}


/*
* Inheritance chain: GameObject -> CharacterStats -> Humanoid
* Instances of Humanoid should have all of the same properties as CharacterStats and GameObject.
* Instances of CharacterStats should have all of the same properties as GameObject.
*/

// Test you work by un-commenting these 3 objects and the list of console logs below:


const mage = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 1,
height: 1,
},
healthPoints: 5,
attackPoints: 7,
name: 'Bruce',
team: 'Mage Guild',
weapons: [
'Staff of Shamalama',
],
language: 'Common Tongue',
});

const swordsman = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 2,
height: 2,
},
healthPoints: 15,
name: 'Sir Mustachio',
team: 'The Round Table',
weapons: [
'Giant Sword',
'Shield',
],
language: 'Common Tongue',
});

const archer = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 1,
width: 2,
height: 4,
},
healthPoints: 10,
name: 'Lilith',
team: 'Forest Kingdom',
weapons: [
'Bow',
'Dagger',
],
language: 'Elvish',
});


const badGuy = new EvilCharacter({
createdAt: new Date(),
dimensions: {
length: 2,
width: 2,
height: 3
},
healthPoints: 15,
attackPoints: 4,
name: "Sir EVILTON",
team: "THE GROUP OF EV1L",
weapons: [
"Dagger",
"Feet",
],
language: "Common Tongue",
})




// console.log(mage.createdAt); // Today's date
// console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
// console.log(swordsman.healthPoints); // 15
// console.log(mage.name); // Bruce
// console.log(swordsman.team); // The Round Table
// console.log(mage.weapons); // Staff of Shamalama
// console.log(archer.language); // Elvish
// console.log(archer.greet()); // Lilith offers a greeting in Elvish.
// console.log(mage.takeDamage()); // Bruce took damage.
// console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.


console.log(badGuy.greet());
console.log(badGuy.threaten());
console.log(badGuy.attack());
console.log(mage.getHit(badGuy));
console.log(mage.attack(badGuy));
console.log(badGuy.getHit(mage));
console.log(mage.getHit(badGuy));
console.log(mage.destroy());