Skip to content

initial commit #692

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit 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
135 changes: 135 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,136 @@
// CODE here for your Lambda Classes
class Person {
constructor(personAttr) {
this.name = personAttr.name;
this.age = personAttr.age;
this.location = personAttr.location;
this.gender = personAttr.gender;
};

speak() {
return `Hello my name is ${this.name}, I am from ${this.location}.`;
};
};

class Instructor extends Person {
constructor(instructorAttr) {
super(instructorAttr);
this.specialty = instructorAttr.specialty;
this.faveLanguage = instructorAttr.faveLanguage;
this.catchPhrase = instructorAttr.catchPhrase;
};

demo(subject) {
return `Today we are learning about ${subject}.`;
};

grade(student, subject) {
return `${student.name} receives a perfect score on ${subject}.`;
};
};

class Student extends Person {
constructor(studentAttr) {
super(studentAttr);
this.previousBackground = studentAttr.previousBackground;
this.className = studentAttr.className;
this.favSubjects = studentAttr.favSubjects;
};

listSubjects() {
let i = 0;
while (i<this.favSubjects.length, i++){
return `I like ${this.favSubjects[i]}`;
}
};

PRAssignment(subject) {
return `${this.name} has submitted a PR for ${subject}.`;
};

sprintChallenge(subject){
return `${this.name} has begun Sprint Challenge for ${subject}.`;
};
};

class TeamLeader extends Instructor {
constructor(PMAttr) {
super(PMAttr);
this.gradClassName = PMAttr.gradClassName;
this.favInstructor = PMAttr.favInstructor;
};

standUp(channel) {
return `${this.name} announces to ${channel}, "@channel standup time!"`;
};

debugsCode(student, subject) {
return `${this.name} debugs ${student.name}'s code on ${subject}.`;
};
}

const dan = new Instructor({
name: 'Dan',
age: 35,
location: 'SLC',
gender: 'Male',
specialty: 'Front End Development',
faveLanguage: 'C++',
catchPhrase: 'Alright, let\'s get started.'
});

const vick = new TeamLeader({
name: 'Vick',
age: 30,
location: 'Puerto Rico',
gender: 'Male',
specialty: 'Junior Fullstack Development',
faveLanguage: 'Javascript',
catchPhrase: 'Looks good to me.',
gradClassName: 'webpt',
favInstructor: 'Dan'
});

const jess = new Student({
name: 'Jess',
age: 31,
location: 'Las Vegas',
gender: 'Female',
previousBackground: 'customer service',
className: 'web25',
favSubjects: ['HTML', 'CSS', 'LESS']
});

console.log(dan.name);
console.log(dan.age);
console.log(dan.location);
console.log(dan.gender);
console.log(dan.specialty);
console.log(dan.faveLanguage);
console.log(dan.catchPhrase);
console.log(vick.name);
console.log(vick.age);
console.log(vick.location);
console.log(vick.gender);
console.log(vick.specialty);
console.log(vick.faveLanguage);
console.log(vick.catchPhrase);
console.log(vick.gradClassName);
console.log(vick.favInstructor);
console.log(jess.name);
console.log(jess.age);
console.log(jess.location);
console.log(jess.gender);
console.log(jess.previousBackground);
console.log(jess.className);
console.log(jess.favSubjects);
console.log(dan.speak());
console.log(vick.speak());
console.log(jess.speak());
console.log(dan.demo('Javascript'));
console.log(dan.grade(jess, 'Javascript'));
console.log(vick.standUp('web25_Vick'));
console.log(vick.debugsCode(jess, 'Javascript'));
console.log(jess.listSubjects());
console.log(jess.PRAssignment('Javascript'));
console.log(jess.sprintChallenge('LESS'));
99 changes: 91 additions & 8 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,92 @@
/*
// Here we have a functioning solutoin to your challenge from yesterday.
// 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.

Prototype Refactor

1. Copy and paste your code or the solution from yesterday

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(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}

destroy() {
return `Object was removed from the game.`
}
}

class CharacterStats extends GameObject {
constructor(characterStatsOptions) {
super(characterStatsOptions);
this.hp = characterStatsOptions.hp;
this.name = characterStatsOptions.name;0
}

takeDamage() {
return `${this.name} took damage.`
}
}

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(),
dimensions: {
length: 2,
width: 1,
height: 1
},
hp: 5,
name: 'Bruce',
faction: 'Mage Guild',
weapons: ['Staff of Shamalama'],
language: 'Common Toungue'
});

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

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

console.log(mage.createdAt); // Today's date
console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
console.log(swordsman.hp); // 15
console.log(mage.name); // Bruce
console.log(swordsman.faction); // 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.