C Sharp Triangle Class

Platform:  .NET
Published  Jun 20, 2010
Updated  Jun 20, 2010
Not Yet completely finished... at least in my mind. Feel free to use this code in your own projects. using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Geometry
{
public class triangle
{
public triangle(double GivenBase, double GivenHeight, double GivenHypotenuse, string GivenType,
double GivenAA = 0, double GivenBA = 0, double GivenCA= 0)
{
Base_Length = GivenBase;
Height_Length = GivenHeight;
Hypotenuse_Length = GivenHypotenuse;
if (GivenType == "right")
{
if (GivenAA != 0 || GivenBA != 0 || GivenCA != 0)
{
A_Degrees = GivenAA;
B_Degrees = GivenBA;
C_Degrees = GivenCA;
}
else
{
C_Degrees = 90;
B_Radians = Math.Asin(Base_Length / Hypotenuse_Length);
A_Radians = Math.Asin(Height_Length / Hypotenuse_Length);
B_Degrees = RadianToDegree(B_Radians);
A_Degrees = RadianToDegree(A_Radians);
}

}
else
{
Type = GivenType;
A_Degrees = GivenAA;
B_Degrees = GivenBA;
C_Degrees = GivenCA;
}


}

private double Base_Length, Height_Length, Hypotenuse_Length;
private double A_Degrees, B_Degrees, C_Degrees, A_Radians, B_Radians;
string Type;

private double RadianToDegree(double angle)
{
return angle * (180.0 / Math.PI);
}

public void WriteAngles()
{
Console.WriteLine("Angle A: {0,5}. Angle B: {1,5}. Angle C: {2,5}", A_Degrees.ToString(), B_Degrees.ToString(), C_Degrees.ToString());
}

public void WriteLengths()
{
Console.WriteLine("Base: {0,5}. Height: {1,5}. Hypotenuse: {2,5}.", Base_Length.ToString(), Height_Length.ToString(), Hypotenuse_Length.ToString());
}

public void WriteInfo()
{
WriteAngles();
WriteLengths();
}

public double GetAngleA()
{
return A_Degrees;
}
public double GetAngleB()
{
return B_Degrees;
}
public double GetAngleC()
{
return C_Degrees;
}
public double GetBaseLength()
{
return Base_Length;
}
public double GetHeightLength()
{
return Height_Length;
}
public double GetHypotenuseLength()
{
return Hypotenuse_Length;
}

}
}

Comments

Sign in to comment.
newbattery   -  Jan 07, 2011
 Respond  
newbattery   -  Jan 07, 2011
Our digital camera battery online shop here,
<a href="http://www.winbatterycharger.com/kodak-easyshare-v705-digital-camera-battery-imhn.htm">kodak easyshare v705 digital camera battery</a>
<a href="http://www.winbatterycharger.com/fujifilm-finepix-f610-digital-camera-battery-imhn.htm">fujifilm finepix f610 digital camera battery</a>
<a href="http://www.winbatterycharger.com/olympus-fe-160-digital-camera-battery-imhn.htm">olympus fe-160 digital camera battery</a>
is your best choice to find best battery selection at the best prices.
<a href="http://www.winbatterycharger.com/hitachi-dz-bp07pw-camcorder-battery-imhn.htm">hitachi dz-bp07pw camcorder battery</a>
<a href="http://www.winbatterycharger.com/casio-np-100-digital-camera-battery-imhn.htm">casio np-100 digital camera battery</a>
Also we stock many chargers for these batteries. Shopping is easy and secure
<a href="http://www.winbatterycharger.com/dell-inspiron-e1505-laptop-battery-imhn.htm">dell inspiron e1505 laptop battery</a>
<a href="http://www.winbatterycharger.com/hp-pavilion-dv4000-series-laptop-battery-imhn.htm">hp pavilion dv4000 series laptop battery</a>
<a href="http://www.winbatterycharger.com/nikon-en-el2-digital-camera-battery-imhn.htm">nikon en-el2 digital camera battery</a>
 Respond  
Jethro   -  Dec 15, 2010
Season's greetings from spammers all 'round the world. ;>
 Respond  
napa182   -  Dec 15, 2010
spammers hitting a new pathetic low =/
 Respond  
xiaole001   -  Dec 15, 2010
sell digital camera battery charger,It should be me like one
panasonic batteries
Digital camera batteries
laptop battery
 Respond  
battery   -  Dec 15, 2010
<a href="http://www.all-good-batteries.com/">panasonic batteries</a>
 Respond  
battery   -  Dec 15, 2010
so good
 Respond  
digitalcharger   -  Jun 22, 2010
<a href="http://www.batteries-charger.co.uk/">batteries charger</a><br />
<a href="http://www.buy-sony-battery-charger.co.uk/">sony battery charger</a><br />
<a href="http://www.buy-battery-charger.co.uk/"> buy battery charger</a><br />
<a href="http://www.digital-camera-battery-charger.net/">digital camera battery charger</a><br />
<a href="http://www.gateway-laptop-keyboard.com/">gateway laptop keyboard</a><br />

batteries charger
sony battery charger
gateway laptop keyboard
buy battery charger
digita camera battery charger
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.