diff --git a/structure-and-scale/main.go b/structure-and-scale/main.go index f558efb..cc619ba 100644 --- a/structure-and-scale/main.go +++ b/structure-and-scale/main.go @@ -10,6 +10,7 @@ func main() { mux := http.NewServeMux() mux.Handle("GET /dice-library/", http.StripPrefix("/dice-library", http.FileServer(http.Dir("dice-library")))) + mux.Handle("GET /treasure-chest/", http.StripPrefix("/treasure-chest", http.FileServer(http.Dir("treasure-chest")))) log.Println("Start the web server...") err := http.ListenAndServe(":8080", mux) diff --git a/structure-and-scale/treasure-chest/README.md b/structure-and-scale/treasure-chest/README.md new file mode 100644 index 0000000..b3f086f --- /dev/null +++ b/structure-and-scale/treasure-chest/README.md @@ -0,0 +1,8 @@ +# Treasure Chest Library + +A library that pirates can use to track the amount of loot they find +on their travels. + +# References + +* https://leanwebclub.com/learn/structure-and-scale/project-treasure-chest-library/ diff --git a/structure-and-scale/treasure-chest/index.html b/structure-and-scale/treasure-chest/index.html new file mode 100644 index 0000000..ccad47d --- /dev/null +++ b/structure-and-scale/treasure-chest/index.html @@ -0,0 +1,15 @@ + + + + + + + Treasure Chest + + +

Treasure Chest

+

All of the magic here happens in the console.

+ + + + diff --git a/structure-and-scale/treasure-chest/script.js b/structure-and-scale/treasure-chest/script.js new file mode 100644 index 0000000..5cb4705 --- /dev/null +++ b/structure-and-scale/treasure-chest/script.js @@ -0,0 +1,26 @@ +let TreasureChest = (function () { + function Constructor () { + this.gold = 0; + this.silver = 0; + this.bronze = 0; + } + + Constructor.prototype.addGold = function (qty) { + this.gold += qty; + } + + Constructor.prototype.addSilver = function (qty) { + this.silver += qty; + } + + Constructor.prototype.addBronze = function (qty) { + this.bronze += qty; + } + + Constructor.prototype.getLoot = function () { + return `Gold: ${this.gold}, Silver: ${this.silver}, Bronze: ${this.bronze}`; + } + + return Constructor; +})(); +