Last active
July 23, 2022 09:29
-
-
Save maxim-saplin/554d0d8216d4b1da26f40d5247c38106 to your computer and use it in GitHub Desktop.
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
import 'dart:math'; | |
const String h = 'kjddHjblwoopwedlradljljlkdfefldlkfdog dgdfgdf'; | |
abstract class A { | |
String getMessage() => 'A'; | |
} | |
class B { | |
String getMessage() => 'B'; | |
} | |
class P { | |
String getMessage() => 'P'; | |
} | |
class AB extends P with A, B {} | |
class BA extends P with B, A {} | |
class CC implements P { | |
CC(this.message, {int howMuch = 3}) { | |
_val = List<int>.generate(howMuch, (index) => index + 1); | |
} | |
CC.four() : this('four', howMuch: 4); | |
final String message; | |
List<int>? _val; | |
List<int> get val => _val!; | |
@override | |
String getMessage() => message; | |
} | |
void main() { | |
String? result; | |
AB ab = new AB(); | |
var ba = BA(); | |
var cc = CC('CC', howMuch: 2); | |
result = ab.getMessage(); | |
print(result); | |
print('ab type: ${ab.runtimeType}'); | |
print("ab is A: " + (ab is A).toString()); | |
print('ab is B: ${ab is B}'); | |
print('ab is P: ${ab is P}'); | |
result = ba.getMessage(); | |
print(result); | |
print(cc.getMessage()); | |
var s = ''; | |
for (var i in cc.val) { | |
s += s.isEmpty ? i.toString() : ', $i' ; | |
} | |
print(s); | |
print(CC.four().getMessage()); | |
var random = Random(1); | |
var x = <int>[1]; | |
for (var i = 0; i < 11; i++) { | |
x.add(h.codeUnitAt(random.nextInt(40))); | |
} | |
print(String.fromCharCodes(x)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment