首页 > 建站教程 > dart >  dart笔记7:dart abstract抽象类正文

dart笔记7:dart abstract抽象类

dart笔记7:dart abstract抽象类:
void main() {
  Square square = Square(100.0, 200.0);
  print(square.area());
}

abstract class Shape {
  double width;
  double height;
  double area();
}

class Square extends Shape {
  Square(double width, double height) {
    this.width = width;
    this.height = height;
  }

  @override
  double area() {
    return super.width * super.height;
  }
}