Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

done #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified async/README.md
100644 → 100755
Empty file.
61 changes: 53 additions & 8 deletions async/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,48 @@ class RNG {

return result;
}

static gatchaRoll(times,callback){
if(times===0){
viewGachaResult(times)
}else{
var simpanarr=[]
for (var i = 0; i < times; i++) {
simpanarr.push(RNG.roll())
}
var max=0
for(let j=0;j<simpanarr.length;j++){
if(simpanarr[j]>max){
max=simpanarr[j]
}
}
callback(max)

}

}

static gatchaRollPromise(times){
return new Promise(function(resolve,reject){
if(times===0){
reject('YAKIN NGGAK MAU NGE-ROLL?')
}else{
var simpanarr=[]
for (var i = 0; i < times; i++) {
simpanarr.push(RNG.roll())
}
var max=0
for(let j=0;j<simpanarr.length;j++){
if(simpanarr[j]>max){
max=simpanarr[j]
}
}
resolve(max)
}

});

}
}

function viewGachaResult(best) {
Expand All @@ -26,7 +68,7 @@ function viewGachaResult(best) {
function viewGachaFailure() {
console.log('YAKIN NGGAK MAU NGE-ROLL?');
}

// console.log(RNG.roll());
// RELEASE 0 TEST CASES
RNG.gatchaRoll(5, function(result) { viewGachaResult(result) }); // output log sesuai hasil random terbaik
RNG.gatchaRoll(1, function(result) { viewGachaResult(result) }); // output log sesuai hasil random terbaik
Expand All @@ -35,17 +77,20 @@ RNG.gatchaRoll(0, function(result) { viewGachaResult(result) }); // output: 0
// RELEASE 1 TEST CASES
RNG.gatchaRollPromise(5)
.then(function(result) { viewGachaResult(result) })
.catch(function(err) { viewGachaFailure() };

// akan menampilkan di log: YOUR BEST GATCHA ROLL RESULT IS <angka antara 1-5>

.catch(function(err) { viewGachaFailure() });
//
// // akan menampilkan di log: YOUR BEST GATCHA ROLL RESULT IS <angka antara 1-5>
//
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?


// RELEASE 2 PROMISE(S)

// code here...
RNG.gatchaRollPromise(5)
.then(function(result) { return result })
.then(function(result) { return result })
.then(function(result1) { console.log(result1);})
.catch(function(err){return err;})
Empty file modified oop/README.md
100644 → 100755
Empty file.
80 changes: 80 additions & 0 deletions oop/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class Robot {
constructor(name) {
this.name= name
}


}

class Baymax extends Robot{
constructor(name) {
super(name)
this.purpose = ''
this.method = ''
}

heal(){
console.log('menuliskan Hi, I am BayMax, how may I help you?')
}
}

class WallE extends Robot{
constructor(name) {
super(name)
this.purpose = 'worker'
this.method = ''
}
work(){
console.log('menuliskan Wall-E cleans the planet')
}
}

class AutoBot extends Robot{
constructor(name) {
super(name)
this.purpose = ''
this.method = ''
}

defend(){
console.log('menuliskan AutoBot, lets roll!')
}
}

class RobotFactory {
constructor() {

}

static produceRobot(nama,jumlah){
var simpan=[]
for(let i=0;i<jumlah;i++){
if (nama==='wall-e') {
simpan.push(new WallE(nama))
}
else if(nama==='baymax'){
simpan.push(new Baymax(nama))
}
else if(nama === 'autobot'){
simpan.push(new AutoBot(nama))
}
}
return simpan
}
}

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();
}
Empty file modified query/.gitignore
100644 → 100755
Empty file.
Empty file modified query/README.md
100644 → 100755
Empty file.
Empty file modified query/database.db
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions query/jawabanquery.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RELEASE 0
select title,point,level,name,age,gender from Status inner join Players ON Status.playerId=Players.id order by level DESC

RELEASE 1
SELECT totalcard,name,age,gender from (select count(*)as totalcard,playerid,name,age,gender from Cards )LEFT JOIN Players ON Cards.playerId=Players.id GROUP BY totalcard GROUP BY Players.id order by totalcard desc limit 3
Empty file modified query/package-lock.json
100644 → 100755
Empty file.
Empty file modified query/package.json
100644 → 100755
Empty file.
Empty file modified query/setup.js
100644 → 100755
Empty file.