Add Treasure Chest Library
This commit is contained in:
parent
35e2f9de20
commit
3dcdcbbac5
4 changed files with 50 additions and 0 deletions
|
@ -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)
|
||||
|
|
8
structure-and-scale/treasure-chest/README.md
Normal file
8
structure-and-scale/treasure-chest/README.md
Normal file
|
@ -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/
|
15
structure-and-scale/treasure-chest/index.html
Normal file
15
structure-and-scale/treasure-chest/index.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
|
||||
<title>Treasure Chest</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Treasure Chest</h1>
|
||||
<p>All of the magic here happens in the console.</p>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
26
structure-and-scale/treasure-chest/script.js
Normal file
26
structure-and-scale/treasure-chest/script.js
Normal file
|
@ -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;
|
||||
})();
|
||||
|
Loading…
Reference in a new issue