Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace _00.Demo { internal class Triangle { private double _a; private double _b; private double _c; private void ValidateSide(double value, string sideName) { if (value <= 0) { throw new ArgumentException($"The side {sideName} has to be more than zero"); } } public double A { get { return this._a; } private set { ValidateSide(value, nameof(A)); this._a = value; } } public double B { get { return this._b; } private set { ValidateSide(value, nameof(B)); this._b = value; } } public double C { get { return this._c; } private set { ValidateSide(value, nameof(A)); this._c = value; } } public Triangle(double a, double b, double c) { if (a + c <= b || b + c <= a || a + b <= c) { throw new ArgumentException("The triangle does not exist"); } this.A = a; this.B = b; this.C = c; } public double P() { return this.A + this.B + this.C; } public double S() { double p = P() / 2; double S = Math.Sqrt(p * (p - this.A) * (p - this.B) * (p - this.C)); return S; } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)