Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Last active October 16, 2024 14:10
Show Gist options
  • Select an option

  • Save gyugyu90/e4433c8d3bbb9caa5f1cdc245c9aee01 to your computer and use it in GitHub Desktop.

Select an option

Save gyugyu90/e4433c8d3bbb9caa5f1cdc245c9aee01 to your computer and use it in GitHub Desktop.
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