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
# https://medium.com/@vivian.muchen/implementing-your-own-time-based-otp-generator-3b971a31330b | |
import hmac | |
import base64 | |
counter = 0 | |
secret = base64.b32encode(b"password") |
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
interface Item { | |
use() | |
} | |
class Pokeball implements Item { // low-level classes depend on abstractions | |
use() | |
} | |
class Medicine implements Item { | |
use() |
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
class Pokeball { // low-level class | |
use() | |
} | |
class Trainer { // high-level class | |
usePokeball(pokeball: Pokeball) { // dependency on lower level class | |
pokeball.use() | |
} | |
} |
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
interface Trainer { | |
choosePokemon(p: Pokemon) | |
} | |
interface SkilledTrainer extends Trainer { | |
switchPokemon(p: Pokemon) | |
} | |
class AceTrainer implements SkilledTrainer { | |
choosePokemon(p) {} |
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
interface Trainer { | |
choosePokemon(p: Pokemon) | |
switchPokemon(p: Pokemon) | |
} | |
class AceTrainer implements Trainer { | |
choosePokemon(p) {} | |
switchPokemon(p) {} | |
} |
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
class Pokemon {} | |
class EvolvablePokemon extends Pokemon { | |
evolve() | |
} | |
class Ditto extends Pokemon {} | |
class Blastoise extends EvolvablePokemon {} |
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
class Pokemon { | |
evolve() | |
} | |
class Ditto extends Pokemon {} |
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
class PokemonType { | |
name string | |
strongAgainstList Array<string> | |
getName(): string { | |
return this.name | |
} | |
getStrongAgainstList(): Array<string> { | |
return this.strongAgainstList | |
} |
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
class Pokemon { | |
getType() | |
beats(enemyPokemon: Pokemon) { | |
if (this.getType() == "Fighting" && enemyPokemon.getType() == "Normal") { | |
return true | |
} else { | |
return false | |
} | |
} | |
} |
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
class Pokemon { | |
getName() | |
getGeneration() | |
getEvolutions() | |
} | |
class PokemonProfile { | |
print(pokemon: Pokemon) | |
} |
NewerOlder