From e123508d38d8803167460ee6ee510c0bf7f72f4d Mon Sep 17 00:00:00 2001 From: Tomek Date: Mon, 6 Apr 2020 15:21:40 +0200 Subject: [PATCH] Nie dopracowany agent --- frontend/index.html | 2 +- frontend/script.js | 9 +++++++++ objects/Agent.js | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 objects/Agent.js diff --git a/frontend/index.html b/frontend/index.html index 1ecdaf3..3389408 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ Inteligentny wózek - diff --git a/frontend/script.js b/frontend/script.js index ba16a09..59de2ab 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -1,8 +1,11 @@ +import Agent from '../objects/Agent.js'; + var regaly = ['1-1', '1-3', '1-4', '1-6', '1-7', '1-9', '2-1', '2-9', '3-3', '3-4', '3-6', '3-7', '4-1', '4-9', '5-1', '5-3', '5-4', '5-6', '5-7', '5-9'] function start(){ ponumerujPola(); pokolorujRegaly(); + umiescAgenta(); } function pokolorujRegaly(){ @@ -22,3 +25,9 @@ function ponumerujPola(){ } } +function umiescAgenta() { + const agent = new Agent(3, 0); + id = agent.getid(); + document.getElementById(id).className = 'regal'; +} + diff --git a/objects/Agent.js b/objects/Agent.js new file mode 100644 index 0000000..eb4cbf2 --- /dev/null +++ b/objects/Agent.js @@ -0,0 +1,12 @@ +class Agent { + constructor(x, y){ + this.xField = x; + this.yField = y; + } + + getid(){ + return this.xField + "-" + this.yField; + } +} + +export default Agent; \ No newline at end of file