Mode entretien. Minuteur de 6 min, sans indices ni autocomplétion
Cuboid and cube
FacileClasses6 min
Write a class Cuboid. The constructor new Cuboid(length, width, height) stores the sizes in the fields length, width and height. The getter volume returns the volume, the getter surfaceArea returns the total surface area.
Then write a class Cube that extends Cuboid. Its constructor takes only the edge length.
Exemples
new Cuboid(1, 2, 3).volumeRenvoie 6
new Cuboid(1, 2, 3).surfaceAreaRenvoie 22
new Cube(2).volumeRenvoie 8
Chargement de l'éditeur...
- The constructor stores the sizes
- Cuboid volume
- Cuboid surface area
- Cube volume and area
- Cube extends Cuboid
Les tests cachés se lancent à la soumission