类属性的get和set

    main(List args) {
    var p = Person();

    p.setName = “33”;
    print(p.getName);
    }

    class Person {
    String name = “”;

    set setName(String name) {
    this.name = name;
    }

    get getName {
    return name;
    }
    }

    类的继承

    class Animal {
    int age;
    Animal(this.age);
    }

    class Person extends Animal {
    String name;
    Person(this.name, int age) : super(age);
    }

    抽象类

    main(List args) {
    var r = Rectangle();
    print(r.getInfo());
    print(r.getArea());
    }

    // 抽象类不能实例化。
    abstract class Shape {
    int getArea();

    String getInfo() {
    return “薪资”;
    }
    }
    // 继承抽象类之后必须实现抽象类的抽象方法。
    class Rectangle extends Shape {
    @override
    int getArea() {
    return 1;
    }
    }

    隐式接口

    main(List args) {}

    class Flyer {
    void flying() {}
    }

    class Runner {
    void Running() {}
    }

    class SuperMan implements Runner, Flyer {
    @override
    void flying() {}
    @override
    void Running() {}
    }