Skip to content

Instantly share code, notes, and snippets.

View gyugyu90's full-sized avatar
🎯
Focusing

Kyuhyeok Park gyugyu90

🎯
Focusing
  • Seoul, Republic of Korea
View GitHub Profile
abstract interface class ToBeImplemented {
void doSomething();
}
class Implementation implements MyClass {
@override
int _privateInstanceVariable = 0;
@override
int instanceVariable = 0;
@override
void _privateMethod() {
// TODO: implement _privateMethod
class MyClass {
static final CONSTANT = 1;
static void staticMethod() {
print('this is static method');
}
int instanceVariable = 2;
final finalInstanceVariable = 3;
abstract class Feed {
void onClick();
}
class PostFeed implements Feed {
@override
void onClick() {
print('show tags');
}
}
abstract class Feed {
void onClick();
}
class PostFeed extends Feed {
@override
void onClick() {
print('show tags');
}
}
void main() {
var headphones = [
BluetoothHeadphone(),
Headphone(),
NoiseCancellingHeadphone()
];
headphones.forEach((headphone) {
headphone.decreaseVolume();
print(headphone.volume); // 4.5, 4.0, 4.8
void main() {
Headphone bluetoothHeadphone = BluetoothHeadphone();
// bluetoothHeadphone.togglePlay(); // Error: The method 'togglePlay' isn't defined for the class 'Headphone'.
bluetoothHeadphone.increaseVolume();
print(bluetoothHeadphone.volume); // 5.5
}
class NoiseCancellingHeadphone extends BluetoothHeadphone {
bool noiseCancellingEnabled = false;
@override
double get volumeUnit => 0.2;
void toggleNoiseCancelling() {
noiseCancellingEnabled = !noiseCancellingEnabled;
}
class Headphone {
double volume = 5;
double volumeUnit = 1;
void increaseVolume() {
if (volume == 10) {
print('최고 볼륨입니다!');
return;
}
class BluetoothHeadphone extends Headphone {
bool isPlaying = false;
void togglePlay() {
isPlaying = !isPlaying;
}
@override
void increaseVolume() {
if (volume == 10) {