Develop a c# windows application for the class circle and write test program to test the circle class.
using System;
using System.Collections.Generic;
namespace СircleApp
{
class Circle
{
private double radius; // Radius of the circle
/**
* Constructor
*
* @param radius The circles radius
*/
public Circle(double radius)
{
this.radius = radius;
}
/**
* Constructor No arg constructor that the sets the radius field to 0.0
*/
public Circle()
{
radius = 0.0;
}
/**
* The setRadius method sets the Circles radius
* @param radius returns radius of the circle
*/
public void setRadius(double radius)
{
this.radius = radius;
}
/**
* The getRadius method
* @return the radius of the circle
*/
public double getRadius()
{
return radius;
}
/**
* The getArea method
* @return the area of the circle
*/
public double getArea()
{
return Math.PI * radius * radius;
}
/**
* The getDiameter method
* @return the diameter of the circle
*/
public double getDiameter()
{
return radius * 2;
}
/**
* The getCircumference method
* @return the circumference of the circle
*/
public double getCircumference()
{
return 2 * Math.PI * radius;
}
}
class Program
{
static void Main(string[] args)
{
Circle circle = new Circle(10);
Console.WriteLine("The radius of the circle: {0} ", circle.getRadius());
Console.WriteLine("The diameter of the circle: {0} ", circle.getDiameter());
Console.WriteLine("The circumference of the circle: {0} ", circle.getCircumference());
Console.WriteLine("The area of the circle: {0} ", circle.getArea());
Console.ReadLine();
}
}
}
Comments
Leave a comment