Skip to content
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ This challenge focuses on classes in JavaScript using the new `class` keyword.

**Follow these steps to set up and work on your project:**

* [ ] Create a forked copy of this project.
* [ ] Add your project manager as collaborator on Github.
* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!).
* [ ] Create a new branch: git checkout -b `<firstName-lastName>`.
* [ ] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
* [ ] Push commits: git push origin `<firstName-lastName>`.
* [x] Create a forked copy of this project.
* [x] Add your project manager as collaborator on Github.
* [x] Clone your OWN version of the repository (Not Lambda's by mistake!).
* [x] Create a new branch: git checkout -b `<firstName-lastName>`.
* [x] Implement the project on your newly created `<firstName-lastName>` branch, committing changes regularly.
* [x] Push commits: git push origin `<firstName-lastName>`.

**Follow these steps for completing your project.**

* [ ] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
* [ ] Add your project manager as a reviewer on the pull-request
* [ ] Your project manager will count the project as complete by merging the branch back into master.
* [x] Submit a Pull-Request to merge <firstName-lastName> Branch into master (student's Repo). **Please don't merge your own pull request**
* [x] Add your project manager as a reviewer on the pull-request
* [x] Your project manager will count the project as complete by merging the branch back into master.

## Assignment Description

Expand Down
92 changes: 92 additions & 0 deletions assignments/lambda-classes.js
Original file line number Diff line number Diff line change
@@ -1 +1,93 @@
// CODE here for your Lambda Classes
class Person{
constructor(properties){
this.name = properties.name;
this.age = properties.age;
this.location = properties.location;
}
speak(){
return `Hello my name is ${this.name}, I am from ${this.location}.`
}
}

class Instructor extends Person{
constructor(properties){
super(properties);
this.specialty = properties.specialty;
this.favLang = properties.favLang;
this.catchPhrase = properties.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(properties){
super(properties);
this.previousBackground = properties.previousBackground;
this.className = properties.className;
this.favSubjects = properties.favSubjects;
}
listsSubjects(){
console.log("My favorite subjects are: ");
return this.favSubjects;
}
PRassignment(Student, subject){
return `${Student.name} has submitted a PR for ${subject}`
}
sprintChallenge(Student, subject){
return `${Student.name} has begun sprint challenge on ${subject}`
}
}

class ProjectManagers extends Instructor{
constructor(properties){
super(properties);
this.gradClassName = properties.gradClassName;
this.favInstructor = properties.favInstructor;
}
standUp(name, channel){
return `${this.name} announces to ${channel}, @channel standy times!`
}
debugsCode(name, Student, subject){
return `${this.name} debugs ${Student.name}'s code on ${subject}`
}
}
const brit = new Instructor({
name: 'Brit',
age: 31,
location: 'Canada',
specialty: 'HTML, CSS, JS',
favLang: 'JavaScript',
catchPhrase: 'Everyone else spells "colour" wrong',

});
const jon = new Student({
name: 'Jon',
age: '22',
location: 'usa',
previousBackground: 'Construction',
className: 'web23',
favSubjects: ['HTML', 'CSS', 'JS']
});
const itel = new ProjectManagers({
name: 'Itel',
age: 28,
location: 'Texas',
specialty: 'Full-Stack Web Dev',
favLang: 'CSS',
gradClassName: 'Web18',
favInstructor: 'Josh Knell'
});
console.log(brit.demo('JavaScript'));
console.log(brit.grade(jon, 'CSS'));
console.log(jon.PRassignment(jon,'JavaScript III'));
console.log(jon.listsSubjects());
console.log(jon.sprintChallenge(jon, 'JavaScript Fundamentals'));
console.log(itel.standUp(itel, 'web_25 itel'));
console.log(itel.debugsCode(itel, jon, 'JavaScript'));
console.log(jon.speak());
151 changes: 151 additions & 0 deletions assignments/prototype-refactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,154 @@ 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.

*/
/*
Object oriented design is commonly used in video games. For this part of the assignment you will be implementing several constructor functions with their correct inheritance hierarchy.

In this file you will be creating three constructor functions: GameObject, CharacterStats, Humanoid.

At the bottom of this file are 3 objects that all end up inheriting from Humanoid. Use the objects at the bottom of the page to test your constructor functions.

Each constructor function has unique properties and methods that are defined in their block comments below:
*/

class GameObject {
constructor(attributes) {
this.createdAt = attributes.createdAt;
this.dimensions = attributes.dimensions;
}
destroy() {
return `${this.name} was killed.`
}
}

class CharacterStats extends GameObject{
constructor(attributes) {
super(attributes);
this.healthPoints = attributes.healthPoints;
this.skillPoints = attributes.skillPoints;
this.level = attributes.level;
this.experience = attributes.experience;
this.name = attributes.name;
}
takeDamage(){
return `${this.name} took damage.`
}
}

class Humanoid extends CharacterStats{
constructor(attributes) {
super(attributes);
this.guild = attributes.guild;
this.faction = attributes.faction;
this.language = attributes.language;
this.weapons = attributes.weapons;
}
greet(){
return `${this.name} says "prepare for battle" in ${this.language}.`
}
}

class Oracle extends Humanoid{
constructor(attributes){
super(attributes);
this.manaPoints = attributes.manaPoints;
this.magicPower = attributes.magicPower;
}
spellHeal(Humanoid){
return `${this.name} uses Healing spell to regenerate life to ${Humanoid.name}.`
}
spellRes(Humanoid){
return `${this.name} casts resurrection spell on ${Humanoid.name}.`
}
}

class Warrior extends Humanoid{
constructor(attributes){
super(attributes);
this.rage = attributes.rage;
this.attackPower = attributes.attackPower;
}
heavyBlow(){
return `${this.name} deals a heavy blow.`
}
}

const oracle = new Oracle({
createdAt: new Date(),
dimensions: {
length: 2,
width: 1,
height: 1,
},
level: 1,
experience: 0,
healthPoints: 5,
skillPoints: 3,
manaPoints: 10,
magicPower: 7,
name: 'Yuui',
guild: 'Legion',
faction: 'Union of Fury',
weapons: ['Optare Rogar II'],
language: 'Vail',
});

const KhaosSlayer = new Warrior({
createdAt: new Date(),
dimensions: {
length: 2,
width: 2,
height: 2,
},
level: 1,
experience: 0,
healthPoints: 15,
skillPoints: 8,
rage: 18,
attackPower: 11,
name: 'KhaosSlayer',
guild: 'Legion',
faction: 'Union of Fury',
weapons: ['Mellan Skia II'],
language: 'Nordein',
});

const ranger = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 1,
width: 2,
height: 4,
},
level: 1,
experience: 0,
healthPoints: 10,
skillPoints: 6,
name: 'Lilith',
guild: 'Forest Kingdom',
faction: 'Alliance of Light',
weapons: ['Artraiya Adein'],
language: 'Human Common',
});

console.log(oracle.createdAt); // Today's date
console.log(ranger.dimensions); // { length: 1, width: 2, height: 4 }
console.log(KhaosSlayer.healthPoints); // 15
console.log(oracle.name); // Yuui
console.log(KhaosSlayer.faction); // Union of Fury
console.log(oracle.weapons); // Optare Rogar II
console.log(ranger.language); // Vail
console.log(KhaosSlayer.guild); //KhaosSlayer's Guild
console.log(ranger.greet()); // Lilith offers a greeting in common.
console.log(oracle.greet());
console.log(KhaosSlayer.takeDamage()); // Yuui took damage.
console.log(oracle.spellHeal(KhaosSlayer));
console.log(KhaosSlayer.destroy()); // KhaosSlayer was killed.
console.log(oracle.spellRes(KhaosSlayer));
console.log(KhaosSlayer.heavyBlow());


// Stretch task:
// * Create Villain and Hero constructor functions that inherit from the Humanoid constructor function.
// * Give the Hero and Villains different methods that could be used to remove health points from objects which could result in destruction if health gets to 0 or drops below 0;
// * Create two new objects, one a villain and one a hero and fight it out with methods!