Created
December 16, 2019 23:16
-
-
Save BNSby/f92a15058cecaf17dd6f67f58cc52039 to your computer and use it in GitHub Desktop.
Изучаем Dart 2019 / ДЗ по классам и наследованию / Задача 2
This file contains hidden or 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
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