Created with <3 with dartpad.dev.
Created
July 14, 2022 13:00
-
-
Save darknight1604/a65c1837bc4b7471ca8c115b8bfba475 to your computer and use it in GitHub Desktop.
fascinating-dryad-3978
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
void main() { | |
Cloneable computer1 = Computer('Asus'); | |
Cloneable computer2 = computer1.clone(); | |
print(computer1.toString()); | |
print(computer2.toString()); | |
} | |
abstract class Cloneable { | |
Cloneable(); | |
Cloneable clone(); | |
} | |
class Computer extends Cloneable { | |
final String model; | |
Computer(this.model) : super(); | |
@override | |
Cloneable clone() { | |
return Computer(model); | |
} | |
@override | |
String toString() => | |
'hashCode: $hashCode, model: $model, runtimeType: $runtimeType'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment