From 8b9747b413cb0d3695e3c1bf4e1f16c73ca62778 Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:11:09 -0500 Subject: [PATCH 1/7] gets started on lab --- food.js | 16 +++++++++++++++- package-lock.json | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/food.js b/food.js index 7fd40ce..972bf7b 100644 --- a/food.js +++ b/food.js @@ -1,4 +1,18 @@ // Create class below - +class Food { + constructor(name, daysToSpoil, fresh = true) { + this.name = name; + this.daysRoSpoil = daysToSpoil; + this.fresh = fresh + } + prepare() { + console.log(`${this.name} is being prepared`) + } + isFresh() { + if(this.fresh == false || this.daysToSpoil <= 0) { + console.log(`${}`) + } + } +} // Do not edit below this line module.exports = Food; diff --git a/package-lock.json b/package-lock.json index 5ba74ba..4636f32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "oop-fruits-pets-lab-solution", "version": "1.0.0", "license": "ISC", "dependencies": { From 7efb18c42e407be46a5fb6eaaa3d74d2a387c90c Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:15:30 -0500 Subject: [PATCH 2/7] finsishes food class --- food.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/food.js b/food.js index 972bf7b..e4aa13d 100644 --- a/food.js +++ b/food.js @@ -6,11 +6,17 @@ class Food { this.fresh = fresh } prepare() { - console.log(`${this.name} is being prepared`) + console.log(`${this.name} is being prepared.`) } isFresh() { if(this.fresh == false || this.daysToSpoil <= 0) { - console.log(`${}`) + console.log(`${this.name} has gone bad.`) + } else { + console.log(`There are ${this.daysToSpoil} days left before ${this.name} goes bad.`) + } + aDayPasses() { + this.daysToSpoil-- + this.isFresh(); } } } From 0d21a9e154c7869dc7634b541d56b741b9ed5f84 Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:33:42 -0500 Subject: [PATCH 3/7] builds out more of tamagotchi class --- food.js | 10 +++++----- tamagotchi.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/food.js b/food.js index e4aa13d..c9913b2 100644 --- a/food.js +++ b/food.js @@ -2,23 +2,23 @@ class Food { constructor(name, daysToSpoil, fresh = true) { this.name = name; - this.daysRoSpoil = daysToSpoil; + this.daysToSpoil = daysToSpoil; this.fresh = fresh } prepare() { - console.log(`${this.name} is being prepared.`) + console.log(`${this.name} is being prepared`) } isFresh() { if(this.fresh == false || this.daysToSpoil <= 0) { - console.log(`${this.name} has gone bad.`) + console.log(`${this.name} has spoiled.`) } else { - console.log(`There are ${this.daysToSpoil} days left before ${this.name} goes bad.`) + console.log(`There are ${this.daysToSpoil} days left before ${this.name} spoils.`) } + } aDayPasses() { this.daysToSpoil-- this.isFresh(); } - } } // Do not edit below this line module.exports = Food; diff --git a/tamagotchi.js b/tamagotchi.js index 9bd9465..e11857b 100644 --- a/tamagotchi.js +++ b/tamagotchi.js @@ -1,4 +1,38 @@ // Create class below - +class Tamagotchi { + constructor( + name, + energy = 9, + full = 8, + mood = 6, + sick = false, + rehomed = false + ) { + this.name = name; + this.energy = energy; + this.full = full; + this.mood = mood; + this.sick = sick; + this.rehomed = rehomed; + } + greet() { + console.log(`Hey There!, I'm ${this.name}`); + } + status() { + console.log(`My mood is: ${this.mood}!\n I am this full: ${this.full}!\n + My energy is: ${this.energy}!\n`) + if (this.sick === true) + console.log("I am sick\n") + else + console.log("I am not sick\n") + } + eat() { + this.full += 2; + this.energy--; + if(this.full >10) + this.sick = true; + + } +} // Do not edit below this line module.exports = Tamagotchi; From 60d929358b840b0204319f5935d3295d0de9cc35 Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:40:51 -0500 Subject: [PATCH 4/7] completes more of tamagoitchi class --- tamagotchi.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tamagotchi.js b/tamagotchi.js index e11857b..373deba 100644 --- a/tamagotchi.js +++ b/tamagotchi.js @@ -31,7 +31,36 @@ class Tamagotchi { this.energy--; if(this.full >10) this.sick = true; - + } + medicate() { + if (this.sick === true) { + this.full = 9; + this.energy -=3; + this.sick= false; + } + else { + this.energy-- + console.log("refusal to take medicine") + } + } + play() { + if(this.sick === true) { + this.mood-- + this.energy-- + } + else if(this.mood>9) { + this.energy -=2 + this.full-- + } + else if(this.energy<=3) { + this.energy-- + console.log("I am too tired to play") + } + else { + this.mood+=2 + this.energy-- + this.full-- + } } } // Do not edit below this line From 6485e7c8e43fb55ba1f612ca1bc56c9524d1187c Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:42:06 -0500 Subject: [PATCH 5/7] builds sleep functionality --- tamagotchi.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tamagotchi.js b/tamagotchi.js index 373deba..e0ba04d 100644 --- a/tamagotchi.js +++ b/tamagotchi.js @@ -62,6 +62,10 @@ class Tamagotchi { this.full-- } } + sleep() { + this.energy+=4; + this.full-=3 + } } // Do not edit below this line module.exports = Tamagotchi; From c25a8b257a7891e3ad4fec0b73086ad139aebcc5 Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:44:20 -0500 Subject: [PATCH 6/7] completes timePasses method --- tamagotchi.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tamagotchi.js b/tamagotchi.js index e0ba04d..11ea549 100644 --- a/tamagotchi.js +++ b/tamagotchi.js @@ -66,6 +66,18 @@ class Tamagotchi { this.energy+=4; this.full-=3 } + timePasses() { + if(this.sick !== true) { + this.mood-=2 + this.full-- + this.energy-- + } + else if(this.sick == true) { + this.mood-=3; + this.full-=2 + this.energy-=2 + } + } } // Do not edit below this line module.exports = Tamagotchi; From 103ebe55216b51dba47a6abbbe8ac5075646f6bd Mon Sep 17 00:00:00 2001 From: Alexander Tsiklidis Date: Thu, 25 Jan 2024 18:46:20 -0500 Subject: [PATCH 7/7] completes lab --- tamagotchi.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tamagotchi.js b/tamagotchi.js index 11ea549..95de369 100644 --- a/tamagotchi.js +++ b/tamagotchi.js @@ -78,6 +78,17 @@ class Tamagotchi { this.energy-=2 } } + badGuardian() { + console.log(`${this.name} has been rehomed`) + if (this.energy <= 0) + this.rehomed = true + if (this.mood <= 0) + this.rehomed = true + if (this.full <= true) + this.rehomed = true + } } + + // Do not edit below this line module.exports = Tamagotchi;