Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- doSmth(MongoDB());
- }
- void doSmth(DB db) {
- final success = db.create('Ahmed', 'name');
- if (success)
- print('Succeeded');
- else
- print('Failed');
- }
- enum EatingType { meat, plant, both }
- abstract class DB {
- bool create(String value, String key);
- String read(String key);
- bool update(String newValue, String key);
- bool delete(String key);
- }
- class MongoDB implements DB {
- @override
- bool create(String value, String key) => false;
- @override
- bool delete(String key) => true;
- @override
- String read(String key) => 'Mohammed';
- @override
- bool update(String newValue, String key) => false;
- }
- class FirestoreDB implements DB {
- @override
- bool create(String value, String key) {
- //lsdjflk
- //lkjsdf
- //lkjadsf
- //lksjdf
- return true;
- }
- @override
- bool delete(String key) => false;
- @override
- String read(String key) => 'Ahmed';
- @override
- bool update(String newValue, String key) => true;
- }
- abstract class Animal {
- Animal(this.age, this.eatingType, this.legsCount);
- int age;
- final EatingType eatingType;
- final int legsCount;
- String speak();
- @override
- String toString() =>
- 'Age: $age, Eating Type: $eatingType, Legs Count: $legsCount, and says: ${speak()}';
- }
- class Cat extends Animal {
- Cat(int age) : super(age, EatingType.meat, 4);
- @override
- String speak() => 'Meoow';
- String play() => 'Playing smth';
- }
- class Cow extends Animal {
- Cow(int age) : super(age, EatingType.plant, 4);
- @override
- String speak() => 'Mooo';
- }
- z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement