Skip to content

Instantly share code, notes, and snippets.

@BNSby
Created December 16, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BNSby/f92a15058cecaf17dd6f67f58cc52039 to your computer and use it in GitHub Desktop.
Save BNSby/f92a15058cecaf17dd6f67f58cc52039 to your computer and use it in GitHub Desktop.
Изучаем Dart 2019 / ДЗ по классам и наследованию / Задача 2
void main() {
Cuboid cuboid = Cuboid(1, 2, 3);
Cube cube = Cube(2);
print('cuboid.Volume - ${cuboid.Volume}');
print('cuboid.SurfaceArea - ${cuboid.SurfaceArea}');
print('');
print('cube.Volume - ${cube.Volume}');
print('cube.SurfaceArea - ${cube.SurfaceArea}');
}
class Cuboid {
int length, width, height;
Cuboid(this.length, this.width, this.height);
// возвращает площадь поверхности прямоугольного параллелепипеда
int get SurfaceArea {
return 2 * (length * width + length * height + width * height);
}
// возвращает объем кубоида (прямоугольного параллелепипеда)
int get Volume {
return length * width * height;
}
}
class Cube extends Cuboid {
int length;
Cube(this.length) : super(length, length, length) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment