diff --git a/lesson08/ToyCustomObject.html b/lesson08/ToyCustomObject.html new file mode 100644 index 0000000..be5c42d --- /dev/null +++ b/lesson08/ToyCustomObject.html @@ -0,0 +1,24 @@ + + + + + Toy Custom Object + + + +

CIW JavaScript Specialist

+

Toy Custom Object

+ + + \ No newline at end of file diff --git a/lesson08/animals.html b/lesson08/animals.html new file mode 100644 index 0000000..1c9b281 --- /dev/null +++ b/lesson08/animals.html @@ -0,0 +1,22 @@ + + + + + JavaScript ES6 Classes + + + + +

CIW JavaScript Specialist

+

JavaScript ES6 Classes

+ + + + + + \ No newline at end of file diff --git a/lesson08/animals.js b/lesson08/animals.js new file mode 100644 index 0000000..343948b --- /dev/null +++ b/lesson08/animals.js @@ -0,0 +1,44 @@ +class Animal { + constructor(name) { + // Property + this.name = name; + } + // Methods + speak() { + return (this.name + ' makes a noise.'); + } + toString() { + return (this.name + ' is an animal. ' + this.speak()); + } +} +// Subclass +class Cat extends Animal { + speak() { + return (this.name + ' meows.'); + } + toString() { + return (this.name + ' is a cat. ' + this.speak()); + } +} +// Subclass +class Dog extends Animal { + speak() { + return (this.name + ' barks.'); + } + toString() { + return (this.name + ' is a dog. ' + this.speak()) + } +} +// Subclass +class Goat extends Animal { + constructor(name, age) { + super(name); + this.age = age; + } + speak() { + return (this.name + ' bleats.'); + } + toString() { + return (this.name + ' is a goat. ' + this.speak() + ' ' + this.name + ' is ' + this.age + ' years old.'); + } +} \ No newline at end of file diff --git a/lesson08/book.js b/lesson08/book.js new file mode 100644 index 0000000..d096970 --- /dev/null +++ b/lesson08/book.js @@ -0,0 +1,21 @@ +//Define book constructor pass three parameter +function Book(theTitle,theAuthor,thePrice) { + //assign parameter to properties of custom object + this.title = theTitle; + this.author = theAuthor; + this.price = thePrice; + //define method call show, which call function showProps + this.show = showProps; +}; + +function showProps() { + var result = ''; + //for i in this statement, display all the properties + for (var i in this) { + //however it will not display when(i is 'show' which is book object, or i is 'addTax' ) + if (i == 'show' || i == 'addTax') continue; + //assign result : property name = value of property, and increment + result += i + '=' + this[i] + '
'; + } + return result; +}; \ No newline at end of file diff --git a/lesson08/dropDownArray.html b/lesson08/dropDownArray.html new file mode 100644 index 0000000..cb913e8 --- /dev/null +++ b/lesson08/dropDownArray.html @@ -0,0 +1,39 @@ + + + + + Employee Database + + + + +

CIW JavaScript Specialist

+

Employee Database

+
+ Select a name to view information: + + +

+
+ + \ No newline at end of file diff --git a/lesson08/employee.js b/lesson08/employee.js new file mode 100644 index 0000000..23e7167 --- /dev/null +++ b/lesson08/employee.js @@ -0,0 +1,22 @@ +function employeeObject(theName,theDepartment,theExtension) { + this.name = theName; + this.department = theDepartment; + this.extension = theExtension; + this.showEmployee = showEmployee; +}; +function showEmployee() { + var info = ''; + info += 'Employee: '+this.name+'\n'; + info += 'Department: '+this.department+'\n'; + info += 'Extension: '+this.extension+'\n'; + alert(info); +}; +function showAllEmployees() { + var info = ''; + for (var i=1;i + + + + Soldier Custom Object + + + +

CIW JavaScript Specialist

+

Soldier Custom Object

+ + + \ No newline at end of file diff --git a/lesson08/language.js b/lesson08/language.js new file mode 100644 index 0000000..32d3d20 --- /dev/null +++ b/lesson08/language.js @@ -0,0 +1,30 @@ +function WebLanguages(myName,myBestPart,myEaseToLearn,myRating) { + this.name = myName; + this.bestPart = myBestPart; + this.easeToLearn = myEaseToLearn; + this.rating = myRating; +}; +function show(languageShow) { + document.write('Language Name: '+languageShow.name+'
'); + document.write('Best Part: '+languageShow.bestPart+'
'); + document.write('Ease of Learning: '+languageShow.easeToLearn+ + '
'); + document.write('Rating 1 to 10: '+languageShow.rating+'
'); + document.write('
'); +}; + +var JS = new WebLanguages('JavaScript','Makes cool effects', + 'Moderate',10); +var JV = new WebLanguages('Java', + 'Makes platform-independent applications','Hard',8); +var HT = new WebLanguages('HTML5/CSS', + 'Makes pretty pages','Easy',9); + +function start() { + document.write('

JavaScript Specialist

'); + document.write('

Rating Web Languages

'); + //show object passing HT variable which contains webLangagues custom object. + show(HT); + show(JS); + show(JV); +}; \ No newline at end of file diff --git a/lesson08/multipleCustomObject.html b/lesson08/multipleCustomObject.html new file mode 100644 index 0000000..3d66e11 --- /dev/null +++ b/lesson08/multipleCustomObject.html @@ -0,0 +1,41 @@ + + + + + House Custom Object + + + +

CIW JavaScript Specialist

+

House Custom Object

+ + + \ No newline at end of file diff --git a/lesson08/ratingWebLanguages.html b/lesson08/ratingWebLanguages.html new file mode 100644 index 0000000..0c95727 --- /dev/null +++ b/lesson08/ratingWebLanguages.html @@ -0,0 +1,10 @@ + + + + + Web Languages Custom Object + + + + + \ No newline at end of file diff --git a/lesson08/usePrototype.html b/lesson08/usePrototype.html new file mode 100644 index 0000000..9b83dba --- /dev/null +++ b/lesson08/usePrototype.html @@ -0,0 +1,31 @@ + + + + + Book Custom Object + + + +

CIW JavaScript Specialist

+

Book Custom Object

+ + + \ No newline at end of file