Last active
October 16, 2024 14:10
-
-
Save gyugyu90/e4433c8d3bbb9caa5f1cdc245c9aee01 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; | |
| double volumeUnit = 1; | |
| void increaseVolume() { | |
| if (volume == 10) { | |
| print('최고 볼륨입니다!'); | |
| return; | |
| } | |
| volume += volumeUnit; | |
| } | |
| void decreaseVolume() { | |
| if (volume == 0) { | |
| print('최저 볼륨입니다!'); | |
| return; | |
| } | |
| volume -= volumeUnit; | |
| } | |
| } | |
| class BluetoothHeadphone extends Headphone { | |
| bool isPlaying = false; | |
| @override | |
| double get volumeUnit => 0.5; | |
| void togglePlay() { | |
| isPlaying = !isPlaying; | |
| } | |
| } | |
| void main() { | |
| BluetoothHeadphone bluetoothHeadphone = BluetoothHeadphone(); | |
| bluetoothHeadphone.increaseVolume(); | |
| print(bluetoothHeadphone.volume); // 5.5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment