startit/Emne 3/ConsoleApp6/w3cRectangle/Program.cs

42 lines
795 B
C#
Raw Normal View History

2024-11-14 14:50:35 +01:00
using System;
namespace RectangleApplication
{
class Rectangle
{
// Member values
double length;
double width;
public void Acceptdetails()
{
length = 4.5;
width = 3.5;
}
public double GetArea()
{
return length * width;
}
public void Display()
{
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class ExecuteRectangle
{
static void Main(string[] args)
{
Rectangle r = new Rectangle();
r.Acceptdetails();
r.Display();
Console.ReadLine();
}
}
}