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

end #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

end #27

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
25 changes: 23 additions & 2 deletions async/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ class RNG {

return result;
}

static gatchaRoll(times, callback){
if(times == 0){
console.log('0')
}
else{
console.log(RNG.roll())
}
}

static gatchaRollPromise(times){
return new Promise(function(resolve, reject){
if(times == 0){
reject(result)
}
else{
resolve(result)
}
})
}

}

function viewGachaResult(best) {
Expand All @@ -35,13 +56,13 @@ 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() };
.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?

Expand Down
103 changes: 103 additions & 0 deletions oop/robot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class Robot{
constructor(name, purpose){
this._name = name
this._purpose = purpose
}
}

class RobotFactory{
constructor(){
this.robotName = []

}

static produceRobot(name, count){
var arrRobot = []
if(name == 'wall-e'){
for(let i=0; i<count; i++){
var walle = new WallE()
arrRobot.push(walle)

}
return arrRobot
}
else if(name == 'baymax'){
for(let i=0; i<count; i++){
var baymax = new BayMax()
arrRobot.push(baymax)

}
return arrRobot
}
else if(name == 'autobot'){
for(let i=0; i<count; i++){
var autobot = new AutoBot()
arrRobot.push(autobot)

}
return arrRobot
}
}
}
class WallE extends Robot{
constructor(name, purpose){
super(name, purpose)
this._name = 'Wall-E'
this._purpose = 'worker'
this.work = this.work()

}

work(){
return 'Wall-E cleans the planet'
}
}

class BayMax extends Robot{
constructor(name, purpose, heal){
super(name, purpose)
this._name = 'BayMax'
this._purpose = 'medic'
this.heal = this.heal()
}

heal(){
return 'Hi, I am BayMax, how may I help you?'
}
}

class AutoBot extends Robot{
constructor(name, purpose, defend){
super(name, purpose)
this._name = 'AutoBot'
this._purpose = 'defend'
this.defend = this.defend()
}

defend(){
return `AutoBot, let's roll!`
}


}

let robot = new WallE()
// console.log(walle.work)
// WallE.work()
// console.log(robot)

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();
// }
Binary file modified query/database.db
Binary file not shown.
1 change: 1 addition & 0 deletions query/note-SQL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
S