8000 Myco sullivan by mjs001 · Pull Request #677 · bloominstituteoftechnology/JavaScript-IV · GitHub
[go: up one dir, main page]

Skip to content

Myco sullivan #677

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
145 changes: 144 additions & 1 deletion assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,144 @@
// CODE here for your Lambda Classes
//Classes:

class Person{
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 Person{
constructor(InstructorAttributes){
super(InstructorAttributes);
this.specialty = InstructorAttributes.specialty,
this.favLanguage = InstructorAttributes.favLanguage,
this.catchPhrase = InstructorAttributes.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 Instructor{
constructor(StudentAttributes){
super(StudentAttributes);
this.previousBackground = StudentAttributes.previousBackground,
this.className = StudentAttributes.className,
this.favSubjects = StudentAttributes.favSubjects
}
listsSubjects(){
return `${this.favSubjects}`
}
PRAssignment(student, subject){
return `${student.name} has submitted a PR for ${subject}`;
}
}



class ProjectManager extends Student{
constructor(ProjectManagerAttributes){
super(ProjectManagerAttributes);
this.gradClassName = ProjectManagerAttributes.gradClassName,
this.favInstructor = ProjectManagerAttributes.favInstructor
}
standUp(channel){
return `${this.name} announces to ${channel}, @channel stand times!​​​​​`;
}
debugsCode(student, subject ){
return `${this.name} debugs ${student.name}'s code on ${subject}`;
}

}

//______________________________________________________________________
//instructors:

const Jerry = new Instructor({
name: 'Jerry',
location: 'Utah',
age: 42,
favLanguage: 'Java',
specialty: 'Computer Science Theory',
catchPhrase: `Love the whales`
});

const Aya = new Instructor({
name: 'Aya',
location: 'Wisconsin',
age: 48,
favLanguage: 'C++',
specialty: 'DevOps',
catchPhrase: `I like cats`
});

//______________________________________________________________________
//students:


const Jon = new Student({
name: 'Jon',
location: 'Idaho',
age: 36,
previousBackground: `cook`,
className: `CS122`,
favSubjects: `front-end`
});

const Jeremy = new Student({
name: 'Jeremy',
location: 'UK',
age: 22,
previousBackground: `college student`,
className: `CS125`,
favSubjects: `back-end`
});

//______________________________________________________________________
//projectManagers:

const Kate = new ProjectManager({
name: 'Kate',
location: 'New Zealand',
age: 53,
gradClassName: 'Web1',
favInstructor: 'Aya'
});

const Kerin = new ProjectManager({
name: 'Kerin',
location: 'Japan',
age: 37,
gradClassName: 'IOS12',
favInstructor: 'Jerry'
});


//______________________________________________________________________
//console.logs for instructors:

console.log(Jerry.speak());
console.log(Jerry.demo('math'));
console.log(Aya.speak());
console.log(Aya.demo('science'));
console.log(Jerry.grade(Jon, 'Computer Science'))
//______________________________________________________________________
//console.logs for students:

console.log(Jon.)


//______________________________________________________________________
//console.logs for projectManagers:
133 changes: 133 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,137 @@ 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.

/*
=== GameObject ===
* createdAt
* name
* dimensions (These represent the character's size in the video game)
* destroy() // prototype method that returns: `${this.name} was removed from the game.`
*/

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`
}
}



/*
=== CharacterStats ===
* healthPoints
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
* should inherit destroy() from GameObject's prototype
*/
class CharacterStats extends GameObject{
constructor(childAttributes){
super(childAttributes);
this.healthPoints = childAttributes.healthPoints
}
takeDamage(_destroy) {
return `${this.name} took damage.`
};
}

/*
=== Humanoid (Having an appearance or character resembling that of a human.) ===
* team
* weapons
* language
* greet() // prototype method -> returns the string '<object name> offers a greeting in <object language>.'
* should inherit destroy() from GameObject through CharacterStats
* should inherit takeDamage() from CharacterStats
*/

class Humanoid extends CharacterStats {
constructor(grandChildAttributes) {
super(grandChildAttributes);
this.team = grandChildAttributes.team,
this.weapons = grandChildAttributes.weapons,
this.language = grandChildAttributes.language
}
greet(_destroy, _takeDamage) {
return `${this.name} offers a greeting in ${this.language}.`
};
}





/*
* 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,
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',
});

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.

0