Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SnowWhite() {
- this.name = "Snow White👶";
- this.age = 0;
- this.fairness = 0;
- this.colorOfSkin = "white";
- this.goodState = "good";
- this.location = "castle📍";
- this.grow = function () {
- this.age++;
- this.fairness++;
- };
- }
- function EvilQueen() {
- this.name = "Queen👸";
- this.age = 22;
- this.fairness = 9;
- this.mood = "good";
- this.location = "castle📍 ";
- this.fosterDaugther = sw;
- this.TimeOfLife = "Once upon a time";
- this.changeSkinColor = function (color) {
- this.colorOfSkin = color;
- };
- this.askMirror = function (mirror) {
- console.log(
- `${eq.name}: Mirror on the wall, who is the fairest of them all?`
- );
- console.log(`${mir.name} answers: ${mirror.whoIsTheFairest().name}`);
- };
- this.grow = function () {
- this.age++;
- };
- this.askHunter = function () {
- if (hunt.lieToQueen) {
- console.log(`${eq.name} asked ${hunt.name} about ${sw.name}`);
- console.log(`${eq.name}: Did you, ${hunt.name} killed ${sw.name}?`);
- console.log(`${hunt.name}: Yes, my ${eq.name}!`);
- }
- };
- }
- function Mirror() {
- this.name = "magic✨mirror";
- this.abilityToSpeak = true;
- if (this.abilityToSpeak) {
- this.alwaysTellTheTruth = true;
- }
- this.owner = eq;
- this.chicks = [];
- this.whoIsTheFairest = function () {
- return this.chicks.sort((a, b) => b.fairness - a.fairness)[0];
- };
- }
- function Hunter() {
- this.name = "Hunter🧔";
- this.location = "castle📍 ";
- this.goodState = "good";
- lieToQueen = false;
- this.tryToKill = function (who) {
- this.functionName = "kill";
- this.location = "forest📍 ";
- who.location = "forest📍 ";
- console.log(`${this.name} went to ${this.location}`);
- console.log(`${who.name} went to ${who.location}`);
- console.log(`${this.name} tried to ${this.functionName} ${who.name}`);
- console.log(
- `But ${this.name} was too ${this.goodState} and couldn't ${this.functionName} ${who.name}`
- );
- this.lieToQueen = true;
- };
- }
- let sw = new SnowWhite();
- let eq = new EvilQueen();
- let mir = new Mirror();
- let hunt = new Hunter();
- mir.chicks = [sw, eq];
- console.log(`${eq.TimeOfLife} lived a ${eq.name}.`);
- function changeLocation(who, where) {
- console.log(`So, ${who.name} came from ${who.location}`);
- who.location = where + "📍";
- console.log(`to ${who.location}`);
- }
- if (eq.fairness > 5) {
- console.log("She was unbelievably beautiful💅🏻.");
- }
- if (mir.owner == eq) {
- console.log(`${eq.name} had a ${mir.name},`);
- console.log(
- mir.abilityToSpeak ? "which could speak 🗣️, and" : "which couldn't speak..."
- );
- console.log(
- mir.alwaysTellTheTruth
- ? `${mir.name} always tell the truth!`
- : `${mir.name} wasn't speaking truth all the time...`
- );
- console.log(`${eq.name} had a foster daugther ${eq.fosterDaugther.name}`);
- console.log(
- `${eq.name} was asking the mirror several times a day the same question:`
- );
- console.log("\n");
- for (let i = 1; i < 10; i++) {
- sw.grow();
- eq.grow();
- console.log(`Year ${i}:`);
- eq.askMirror(mir);
- }
- }
- console.log(`${sw.name} was growing a ${sw.goodState} person.`);
- console.log(`${eq.name} was in a ${eq.mood} mood!`);
- sw.grow();
- eq.grow();
- console.log(
- `One day ${sw.name} had ${sw.fairness} points of beauty and ${eq.name} had only ${eq.fairness} points of beauty only!`
- );
- eq.askMirror(mir);
- console.log(`So, ${sw.name} `);
- sw.name = "Snow White👸";
- console.log(`became ${sw.name}!`);
- console.log(`But ${eq.name}`);
- eq.name = "Queen👵";
- console.log(`became ${eq.name}!`);
- eq.mood = "bad";
- console.log(`${eq.name} is in a ${eq.mood} mood now!`);
- console.log(`${eq.name} asked ${hunt.name} to kill ${sw.name}`);
- hunt.tryToKill(sw);
- changeLocation(hunt, "castle");
- eq.askHunter();
- // changeLocation(sw, dwarf1.location);
- function Dwarfs() {
- this.name = name
- this.location = "Dwarf's House";
- }
- let dwarfs = [
- { name: "Doc " },
- { name: "Grumpy" },
- { name: "Happy " },
- { name: "Sleepy " },
- { name: "Bashful " },
- { name: "Sneezy" },
- ];
- let dwarfsObjects = dwarfs.map((dwarf) => new Dwarfs(name));
- console.log(dwarfsObjects);
- // eq.changeSkinColor ("green")
- // console.log(`${eq.name} became ${eq.colorOfSkin}`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement