Add Treasure Chest Library

This commit is contained in:
Andrea Fazzi 2024-08-16 15:47:14 +02:00
parent 35e2f9de20
commit 3dcdcbbac5
4 changed files with 50 additions and 0 deletions

View file

@ -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)

View 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/

View 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>

View 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;
})();