Last active
October 16, 2024 13:52
-
-
Save gyugyu90/eabefd52aa096f63e9a2d8485c33852f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Headphone { | |
double volume = 5; | |
void increaseVolume() { | |
if (volume == 10) { | |
print('최고 볼륨입니다!'); | |
return; | |
} | |
volume++; | |
} | |
void decreaseVolume() { | |
if (volume == 0) { | |
print('최저 볼륨입니다!'); | |
return; | |
} | |
volume++; | |
} | |
} | |
class BluetoothHeadphone extends Headphone { | |
bool isPlaying = false; | |
void togglePlay() { | |
isPlaying = !isPlaying; | |
} | |
} | |
class NoiseCancellingHeadphone extends BluetoothHeadphone { | |
bool noiseCancellingEnabled = false; | |
void toggleNoiseCancelling() { | |
noiseCancellingEnabled = !noiseCancellingEnabled; | |
} | |
} | |
void main() { | |
BluetoothHeadphone bluetoothHeadphone = BluetoothHeadphone(); | |
bluetoothHeadphone.increaseVolume(); | |
print(bluetoothHeadphone.volume); // 6 | |
bluetoothHeadphone.togglePlay(); | |
print(bluetoothHeadphone.isPlaying); // false | |
NoiseCancellingHeadphone noiseCancellingHeadphone = | |
NoiseCancellingHeadphone(); | |
noiseCancellingHeadphone.decreaseVolume(); | |
print(noiseCancellingHeadphone.volume); // 4 | |
noiseCancellingHeadphone.togglePlay(); | |
print(noiseCancellingHeadphone.isPlaying); // true | |
noiseCancellingHeadphone.toggleNoiseCancelling(); | |
print(noiseCancellingHeadphone.noiseCancellingEnabled); // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment