/* המחלקה הראשית המשתמשת במחלקה מלבן */ using System; public class TestSolver { public static void Main() { // הגדרת משתנים Rectangle rec; double length; double width; for (int i = 0; i < 4; i++) { // קלט Console.Write("Enter the rectangle length: "); length = double.Parse(Console.ReadLine()); Console.Write("Enter the rectangle width: "); width = double.Parse(Console.ReadLine()); // הקצאת מלבן rec = new Rectangle(length, width); // ביצוע חישובים והצגת פלט Console.WriteLine("The rectangle area is: {0}", rec.Area()); Console.WriteLine("The rectangle perimeter is: {0}", rec.Perimeter()); } // for } // Main } // class TestSolver /* מחלקת מלבן */ public class Rectangle { //הגדרת התכונות private double width; // רוחב private double length; // אורך //פעולה בונה public Rectangle(double length, double width) { this.length = length; this.width = width; } //פעולת שטח public double Area() { return width * length; } //פעולת היקף public double Perimeter() { return 2 * width + 2 * length; } } // class Rectangle