/* מחלקה ראשית המממשת תחרות קפיצה לגובה */ using System; public class JumperContest { public static void Main() { // הגדרה והקצאת משתנים int jumpersNum; Jumper[] jumpers; double jumpHeight; string jumperName; string jumperId; Console.Write("Enter number of jumpers: "); jumpersNum = int.Parse(Console.ReadLine()); jumpers = new Jumper[jumpersNum]; for (int i = 0; i < jumpersNum; i++) { Console.Write("Enter Jumper Name: "); jumperName = Console.ReadLine(); Console.Write("Enter Jumper Id: "); jumperId = Console.ReadLine(); jumpers[i] = new Jumper(jumperName, jumperId); //יצירת כל איבר במערך בתורו Console.Write("Enter Jump Height: "); jumpHeight = int.Parse(Console.ReadLine()); jumpers[i].SetJumpHeight(jumpHeight); } // פלט for (int i = 0; i < jumpersNum - 1; i++) { for (int j = i + 1; j < jumpersNum; j++) { if (jumpers[i].GetJumpHeight() == jumpers[j].GetJumpHeight()) { Console.WriteLine("{0} and {1} jumped the same height: {2}", jumpers[i].GetName(), jumpers[j].GetName(),jumpers[i].GetJumpHeight()); } // if } // for j } // for i } // Main } // class JumperContest /* מחלקת קופץ לגובה */ public class Jumper { // תכונות הקופץ private string name; // שם private string id; // ת"ז private double jumpHeight; // גובה קפיצה // הפעולה הבונה public Jumper(string name, string id) { this.name = name; this.id = id; jumpHeight = 0; } //פעולת גישה: מחזירה את שם הקופץ public string GetName() { return name; } //פעולת גישה: מחזירה את גובה הקפיצה של הקופץ public double GetJumpHeight() { return jumpHeight; } //פעולת גישה: מעדכנת את גובה הקפיצה של הקופץ public void SetJumpHeight(double jumpHeight) { this.jumpHeight = jumpHeight; } } // class Jumper