From 33a122660d33d83c25d3deb21bfdd834809e7b6d Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:12:30 +0300 Subject: [PATCH 01/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-1.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 hw4-1.html diff --git a/hw4-1.html b/hw4-1.html new file mode 100644 index 0000000..e651947 --- /dev/null +++ b/hw4-1.html @@ -0,0 +1,25 @@ + + + From 17eb04e200e04fd21d7588c837070c7509beee46 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:12:56 +0300 Subject: [PATCH 02/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-2_main.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 hw4-2_main.html diff --git a/hw4-2_main.html b/hw4-2_main.html new file mode 100644 index 0000000..0ac192e --- /dev/null +++ b/hw4-2_main.html @@ -0,0 +1,15 @@ + + + + + + + Document + + + + + + + + From aef22e7da91bfb51fc13e3d1ff67a297d0c089b1 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:13:29 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basket.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 basket.js diff --git a/basket.js b/basket.js new file mode 100644 index 0000000..dada1e2 --- /dev/null +++ b/basket.js @@ -0,0 +1,20 @@ +let basket = { + goodlist: [], + + countTotalPrice() { + var priceSum = 0; + for (i in this.goodlist) { + let finalPrice = this.goodlist[i].price * this.goodlist[i].amount; + priceSum += finalPrice; + } + return priceSum; + }, + + countTotalNumber() { + let totalNum = 0; + for (i in this.goodlist) { + totalNum += this.goodlist[i].amount; + } + return totalNum; + } +} From ed7539f75731665855c209d5eb0ac7cd0bb99520 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:13:41 +0300 Subject: [PATCH 04/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 code.js diff --git a/code.js b/code.js new file mode 100644 index 0000000..ce90bb8 --- /dev/null +++ b/code.js @@ -0,0 +1,4 @@ + +console.log(basket); +console.log(basket.countTotalNumber()); +console.log(basket.countTotalPrice()); From 598a4b92fe44ab3b11758761ea83e46be0ed7700 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:13:47 +0300 Subject: [PATCH 05/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goods.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 goods.js diff --git a/goods.js b/goods.js new file mode 100644 index 0000000..94d709a --- /dev/null +++ b/goods.js @@ -0,0 +1,66 @@ +let goods = [ + { + name: 'лампа', + price: 1200, + amount: 4, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'диван', + price: 25000, + amount: 1, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'тумба', + price: 4500, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'зеркало', + price: 5000, + amount: 4, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'шкаф', + price: 35000, + amount: 1, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'туалетный столик', + price: 7000, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'пуфик', + price: 2000, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + } +] +goods.forEach(function(item, i) { + if (i % 2 == 0) { + item.putToBasket(); + } else { + item.putToBasket(); + item.putToBasket(); + } +}); From f6079c38c62842238f7066ef84bb6be3a698d5f3 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:24 +0300 Subject: [PATCH 06/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 hw4-3_index.html diff --git a/hw4-3_index.html b/hw4-3_index.html new file mode 100644 index 0000000..cb15eb7 --- /dev/null +++ b/hw4-3_index.html @@ -0,0 +1,16 @@ + + + + + + + Document + + + + + + + + + From 5d5be0c72e3508ef0c57fd580a614abff9afe479 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:29 +0300 Subject: [PATCH 07/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_code.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 hw4-3_code.js diff --git a/hw4-3_code.js b/hw4-3_code.js new file mode 100644 index 0000000..3e8791d --- /dev/null +++ b/hw4-3_code.js @@ -0,0 +1,28 @@ +let game = { + + run() { + while(true) { + let direction = prompt('Введите направление: 2, 8, 4, 6'); + if (direction === null) { + console.log('Игра окончена'); + return; + } + + let nextPoint = mover.getNextPoint(direction); + renderer.clear(); + player.move(nextPoint); + renderer.render(); + + } + }, + + init() { + console.log('Для начала игры введите команду game.run()'); + renderer.render(); + }, + +}; + + + +game.init(); From 31f0faade8e5a5bd324b5e77017dec57677ef80a Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:34 +0300 Subject: [PATCH 08/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_config.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 hw4-3_config.js diff --git a/hw4-3_config.js b/hw4-3_config.js new file mode 100644 index 0000000..c701297 --- /dev/null +++ b/hw4-3_config.js @@ -0,0 +1,5 @@ + +let config = { + nRows: 10, + nColemns: 10 +}; From 88f780fd266c00201a81e15d2f4fada58491bb21 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:39 +0300 Subject: [PATCH 09/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_mover.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 hw4-3_mover.js diff --git a/hw4-3_mover.js b/hw4-3_mover.js new file mode 100644 index 0000000..eb25222 --- /dev/null +++ b/hw4-3_mover.js @@ -0,0 +1,76 @@ +let mover = { + getNextPoint(direction) { + let nextPoint = { + x: player.x, + y: player.y + } + + switch (direction) { + case '2': + if (player.y == 0) { + nextPoint.y; + } else { + nextPoint.y--; + } + break; + case '6': + if (player.x == 9) { + nextPoint.x; + } else { + nextPoint.x++; + } + break; + case '8': + if (player.y == 9) { + nextPoint.y; + } else { + nextPoint.y++; + } + break; + case '4': + if (player.x == 0) { + nextPoint.x; + } else { + nextPoint.x--; + } + break; + case '3': + if (player.y == 0 || player.x == 9) { + nextPoint.x; + nextPoint.y; + } else { + nextPoint.x++; + nextPoint.y--; + } + break; + case '1': + if (player.x == 0 || player.y == 0) { + nextPoint.x; + nextPoint.y; + } else { + nextPoint.x--; + nextPoint.y--; + } + break; + case '7': + if (player.x == 0 || player.y == 9) { + nextPoint.x; + nextPoint.y; + } else { + nextPoint.x--; + nextPoint.y++; + } + break; + case '9': + if (player.x == 9 || player.y == 9) { + nextPoint.x; + nextPoint.y; + } else { + nextPoint.x++; + nextPoint.y++; + } + break; + } + return nextPoint; + } +}; From 0f1bc1e31ebfe554174fbba9688aa13510f76b5d Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:44 +0300 Subject: [PATCH 10/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_player.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 hw4-3_player.js diff --git a/hw4-3_player.js b/hw4-3_player.js new file mode 100644 index 0000000..a5e0410 --- /dev/null +++ b/hw4-3_player.js @@ -0,0 +1,10 @@ +let player = { + x: 0, + y: 0, + + move(nextPoint) { + this.x = nextPoint.x; + this.y = nextPoint.y; + } +}; + From 0c2f378a7564b85d47da634e3bbd3639cdbbb471 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 18 Feb 2019 16:14:49 +0300 Subject: [PATCH 11/11] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=203=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw4-3_renderer.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 hw4-3_renderer.js diff --git a/hw4-3_renderer.js b/hw4-3_renderer.js new file mode 100644 index 0000000..d67faf9 --- /dev/null +++ b/hw4-3_renderer.js @@ -0,0 +1,33 @@ +/** + * Объект отрисовки карты + */ + + +let renderer = { + map: '', + /** + * Метод отрисовки карты + */ + render() { + + for(let i = 0; i < config.nRows; i++) { + for(let j = 0; j < config.nColemns; j++) { + if (player.x == j && player.y == i) { + this.map += 'o'; + } else { + this.map += 'x'; + } + + } + this.map += '\n'; + } + + + console.log(this.map); + }, + + clear() { + console.clear(); + this.map = ''; + } +};