Last active
October 6, 2016 08:33
-
-
Save yonisetiawan/0a20290a9066139598fb0478e3649cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
class hacktiv{ | |
constructor(siswa){ | |
this.siswa = siswa; | |
} | |
pasangan(){ | |
var peserta = []; | |
var nama = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]; | |
for (var i = 0; i < this.siswa; i++) { | |
peserta.push(nama[i]) | |
} | |
var hasil = []; | |
for (var j = 0; j < peserta.length; j++) { | |
for (var i = 1; i < peserta.length; i++) { | |
if(peserta[j]!==peserta[i]){ | |
hasil.push([peserta[j]+", "+peserta[i]]) | |
} | |
} | |
} | |
return hasil | |
} | |
} | |
class arctic extends hacktiv{ | |
constructor(siswa, pair){ | |
super(siswa) | |
this.pair = pair; | |
} | |
pairarctic(){ | |
var hasil = super.pasangan() | |
return hasil | |
} | |
} | |
class blandfox extends hacktiv{ | |
constructor(siswa, pair){ | |
super(siswa) | |
this.pair = pair; | |
} | |
pairblandfox(){ | |
var hasil = super.pasangan() | |
return hasil | |
} | |
} | |
var arc = new arctic(5) | |
console.log("Kelas ARCTIC") | |
console.log(arc.pairarctic()) | |
console.log("===================="); | |
var bland = new blandfox(5) | |
console.log("Kelas BLANDFOX") | |
console.log(bland.pairblandfox()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment