diff --git a/async/index.js b/async/index.js index 77df3b7..e943520 100644 --- a/async/index.js +++ b/async/index.js @@ -17,6 +17,48 @@ class RNG { return result; } + static gatchaRoll(times, callback){ + setTimeout(function() { + let result = [] + if (times === 0 ){ + callback(0) + }else{ + for(let i =0; iconsole.log(err)) + }else{ + for(let i =0; i +// // akan menampilkan di log: YOUR BEST GATCHA ROLL RESULT IS RNG.gatchaRollPromise(0) .then(function(result) { viewGachaResult(result) }) - .catch(function(err) { viewGachaFailure() }; + .catch(function(err) { viewGachaFailure() }); // akan menampilkan di log: YAKIN NGGAK MAU NGE-ROLL? diff --git a/oop/index.js b/oop/index.js new file mode 100644 index 0000000..a9470fb --- /dev/null +++ b/oop/index.js @@ -0,0 +1,17 @@ +const RobotFactory = require('./robotfactory') + +let wall_e = RobotFactory.produceRobot('wall-e', 6); +let baymax = RobotFactory.produceRobot('baymax', 5); +let autobot = RobotFactory.produceRobot('autobot', 3); + +for (var i = 0; i < wall_e.length; i++) { + wall_e[i].work() +} + +for (var i = 0; i < baymax.length; i++) { + baymax[i].heal(); +} + +for (var i = 0; i < autobot.length; i++) { + autobot[i].defend(); +} \ No newline at end of file diff --git a/oop/robot.js b/oop/robot.js new file mode 100644 index 0000000..e360bd3 --- /dev/null +++ b/oop/robot.js @@ -0,0 +1,44 @@ +class Robot{ + constructor (){ + this.name = 'Robot' + this.purpose = 'purpose' + } +} + +class WallE extends Robot{ + constructor(){ + super() + this.name= 'Wall-E' + this.purpose= 'worker' + } + work(){ + console.log('Wall-E cleans the planet') + } +} + +class BayMax extends Robot{ + constructor(){ + super() + this.name= 'BayMax' + this.purpose= 'medic' + } + heal(){ + console.log('Hi, I am BayMax, how may I help you?') + } +} +class AutoBot extends Robot{ + constructor(){ + super() + this.name = 'AutoBot' + this.purpose= 'defender' + } + defend(){ + console.log("AutoBot, let's roll!") + } +} + +module.exports = { + WallE, + BayMax, + AutoBot +} \ No newline at end of file diff --git a/oop/robotfactory.js b/oop/robotfactory.js new file mode 100644 index 0000000..4a56274 --- /dev/null +++ b/oop/robotfactory.js @@ -0,0 +1,22 @@ +const {WallE,BayMax,AutoBot} = require('./robot') + +class RobotFactory{ + static produceRobot(robot, length){ + let arr = [] + for(let i =0; i{ + if (err) throw err; + //console.log(rows) + }) + + let query2 = `SELECT count(Cards.playerId) as totalCard, playerId, Players.name, age, gender FROM Players + INNER JOIN Cards on Players.id = Cards.playerId + GROUP BY playerId + HAVING Players.gender = 'Male' + ORDER BY totalCard DESC + LIMIT 3` + db.all(query2,(err,rows)=>{ + if (err) throw err; + console.log(rows) + }) +}) + +// tampilkan `player` yang memiliki `jumlah kartu`, dan berjenis kelamin `male` +// serta tampilkan 3 teratas dari yang paling banyak jumlah kartunya. \ No newline at end of file diff --git a/query/package.json b/query/package.json index 85ce79c..7577d4c 100644 --- a/query/package.json +++ b/query/package.json @@ -1,7 +1,7 @@ { "name": "query", "version": "1.0.0", - "description": "", + "description": "### dilarang menggunakan view, sub-query", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1"