Advertisement
AlexandrP

Untitled

Jan 26th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function SnowWhite() {
  2.   this.name = "Snow White👶";
  3.   this.age = 0;
  4.   this.fairness = 0;
  5.   this.colorOfSkin = "white";
  6.   this.goodState = "good";
  7.   this.location = "castle📍";
  8.  
  9.   this.grow = function () {
  10.     this.age++;
  11.     this.fairness++;
  12.   };
  13. }
  14. function EvilQueen() {
  15.   this.name = "Queen👸";
  16.   this.age = 22;
  17.   this.fairness = 9;
  18.   this.mood = "good";
  19.   this.location = "castle📍 ";
  20.   this.fosterDaugther = sw;
  21.   this.TimeOfLife = "Once upon a time";
  22.   this.changeSkinColor = function (color) {
  23.     this.colorOfSkin = color;
  24.   };
  25.  
  26.   this.askMirror = function (mirror) {
  27.     console.log(
  28.       `${eq.name}: Mirror on the wall, who is the fairest of them all?`
  29.     );
  30.     console.log(`${mir.name} answers: ${mirror.whoIsTheFairest().name}`);
  31.   };
  32.   this.grow = function () {
  33.     this.age++;
  34.   };
  35.  
  36.   this.askHunter = function () {
  37.     if (hunt.lieToQueen) {
  38.       console.log(`${eq.name} asked ${hunt.name} about ${sw.name}`);
  39.       console.log(`${eq.name}: Did you, ${hunt.name} killed ${sw.name}?`);
  40.       console.log(`${hunt.name}: Yes, my ${eq.name}!`);
  41.     }
  42.   };
  43. }
  44. function Mirror() {
  45.   this.name = "magic✨mirror";
  46.   this.abilityToSpeak = true;
  47.  
  48.   if (this.abilityToSpeak) {
  49.     this.alwaysTellTheTruth = true;
  50.   }
  51.  
  52.   this.owner = eq;
  53.   this.chicks = [];
  54.  
  55.   this.whoIsTheFairest = function () {
  56.     return this.chicks.sort((a, b) => b.fairness - a.fairness)[0];
  57.   };
  58. }
  59.  
  60. function Hunter() {
  61.   this.name = "Hunter🧔";
  62.   this.location = "castle📍 ";
  63.   this.goodState = "good";
  64.   lieToQueen = false;
  65.   this.tryToKill = function (who) {
  66.     this.functionName = "kill";
  67.     this.location = "forest📍 ";
  68.     who.location = "forest📍 ";
  69.     console.log(`${this.name} went to ${this.location}`);
  70.     console.log(`${who.name} went to ${who.location}`);
  71.  
  72.     console.log(`${this.name} tried to ${this.functionName} ${who.name}`);
  73.  
  74.     console.log(
  75.       `But ${this.name} was too ${this.goodState} and couldn't ${this.functionName} ${who.name}`
  76.    );
  77.    this.lieToQueen = true;
  78.  };
  79. }
  80. let sw = new SnowWhite();
  81. let eq = new EvilQueen();
  82. let mir = new Mirror();
  83. let hunt = new Hunter();
  84.  
  85. mir.chicks = [sw, eq];
  86.  
  87. console.log(`${eq.TimeOfLife} lived a ${eq.name}.`);
  88.  
  89. function changeLocation(who, where) {
  90.  console.log(`So, ${who.name} came from ${who.location}`);
  91.  who.location = where + "📍";
  92.  console.log(`to ${who.location}`);
  93. }
  94.  
  95. if (eq.fairness > 5) {
  96.  console.log("She was unbelievably beautiful💅🏻.");
  97. }
  98.  
  99. if (mir.owner == eq) {
  100.  console.log(`${eq.name} had a ${mir.name},`);
  101.  console.log(
  102.    mir.abilityToSpeak ? "which could speak 🗣️, and" : "which couldn't speak..."
  103.  );
  104.  console.log(
  105.    mir.alwaysTellTheTruth
  106.      ? `${mir.name} always tell the truth!`
  107.      : `${mir.name} wasn't speaking truth all the time...`
  108.  );
  109.  
  110.  console.log(`${eq.name} had a foster daugther ${eq.fosterDaugther.name}`);
  111.  
  112.  console.log(
  113.    `${eq.name} was asking the mirror several times a day the same question:`
  114.  );
  115.  console.log("\n");
  116.  for (let i = 1; i < 10; i++) {
  117.    sw.grow();
  118.    eq.grow();
  119.  
  120.    console.log(`Year ${i}:`);
  121.    eq.askMirror(mir);
  122.  }
  123. }
  124.  
  125. console.log(`${sw.name} was growing a ${sw.goodState} person.`);
  126.  
  127. console.log(`${eq.name} was in a ${eq.mood} mood!`);
  128. sw.grow();
  129. eq.grow();
  130.  
  131. console.log(
  132.  `One day ${sw.name} had ${sw.fairness} points of beauty and ${eq.name} had only ${eq.fairness} points of beauty only!`
  133. );
  134.  
  135. eq.askMirror(mir);
  136.  
  137. console.log(`So, ${sw.name} `);
  138. sw.name = "Snow White👸";
  139. console.log(`became ${sw.name}!`);
  140.  
  141. console.log(`But ${eq.name}`);
  142. eq.name = "Queen👵";
  143.  
  144. console.log(`became ${eq.name}!`);
  145.  
  146. eq.mood = "bad";
  147.  
  148. console.log(`${eq.name} is in a ${eq.mood} mood now!`);
  149.  
  150. console.log(`${eq.name} asked ${hunt.name} to kill ${sw.name}`);
  151.  
  152. hunt.tryToKill(sw);
  153.  
  154. changeLocation(hunt, "castle");
  155.  
  156. eq.askHunter();
  157.  
  158. // changeLocation(sw, dwarf1.location);
  159.  
  160.  
  161.  
  162. function Dwarfs() {
  163.  this.name = name
  164.  this.location = "Dwarf's House";
  165. }
  166. let dwarfs = [
  167.  { name: "Doc " },
  168.  { name: "Grumpy" },
  169.  { name: "Happy " },
  170.  { name: "Sleepy " },
  171.  { name: "Bashful " },
  172.  { name: "Sneezy" },
  173. ];
  174.  
  175. let dwarfsObjects = dwarfs.map((dwarf) => new Dwarfs(name));
  176.  
  177. console.log(dwarfsObjects);
  178.  
  179. // eq.changeSkinColor ("green")
  180. // console.log(`${eq.name} became ${eq.colorOfSkin}`);
  181.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement