Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace E01.ClassBox
- {
- public class Box
- {
- private double lenght;
- private double width;
- private double height;
- public Box(double lenght, double width, double height)
- {
- Lenght = lenght;
- Width = width;
- Height = height;
- }
- private double Lenght
- {
- set
- {
- if (value <= 0)
- {
- throw new ArgumentException($"{nameof(Lenght)} cannot be zero or negative.");
- }
- lenght = value;
- }
- }
- private double Width
- {
- set
- {
- if (value <= 0)
- {
- throw new ArgumentException($"{nameof(Width)} cannot be zero or negative.");
- }
- width = value;
- }
- }
- private double Height
- {
- set
- {
- if (value <= 0)
- {
- throw new ArgumentException($"{nameof(Height)} cannot be zero or negative.");
- }
- height = value;
- }
- }
- public double BoxVolume()
- {
- return lenght * width * height;
- }
- public double BoxLateralSurfArea()
- {
- return 2 * lenght * height + 2 * width * height;
- }
- public double BoxSurfArea()
- {
- return 2 * lenght * width + 2 * lenght * height + 2 * width * height;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement