Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Hosting;
  6. using Microsoft.Extensions.Configuration;
  7. using Microsoft.Extensions.Hosting;
  8. using Microsoft.Extensions.Logging;
  9.  
  10. namespace ffff
  11. {
  12.     public class Program
  13.     {
  14.         public static double LongestLength(Line[] lines)
  15.         {
  16.             double longest = 0.0;
  17.             for (int i = 0; i < lines.Length; i++)
  18.             {
  19.                 if (lines[i].LineLength() > longest)
  20.                 {
  21.                     longest = lines[i].LineLength();
  22.                 }
  23.             }
  24.             return longest;
  25.         }
  26.         public static int CountLines(Point point, Line[]lines){
  27.             for (int i = 0; i < lines. Length; i++) {
  28.                if(lines[i].GetP1() == point || lines[i].GetP2() == point){
  29.                   Console.WriteLine(lines[i]);  
  30.                }
  31.             }
  32.         }
  33.         public static void Main(string[] args)
  34.         {
  35.             Line[] lines = new Line[10];
  36.             int maxL = 0;
  37.             for (int i = 0; i < lines.Length; i++)
  38.             {
  39.                 LongestLength(lines[i]);
  40.             }
  41.         }
  42.     }
  43.     class Point
  44.     {
  45.         private int x;
  46.         private int y;
  47.         public Point(int x , int y)
  48.         {
  49.             this.x = x;
  50.             this.y = y;
  51.         }
  52.         public int GetX()
  53.         {
  54.             return x;
  55.         }
  56.         public void SetX(int x)
  57.         {
  58.             this.x = x;
  59.         }
  60.         public int GetY()
  61.         {
  62.             return y;
  63.         }
  64.         public void SetY(int y)
  65.         {
  66.             this.y = y;
  67.         }
  68.     }
  69.     //: //////////////////////////////////////////
  70.     class Line
  71.     {
  72.         private Point p1;
  73.         private Point p2;
  74.         public Line(Point p1, Point p2)
  75.         {
  76.             this.p1 = p1;
  77.             this.p2 = p2;
  78.         }
  79.         public Point GetP1()
  80.         {
  81.             return p1;
  82.         }
  83.         public void SetP1(Point p1)
  84.         {
  85.             this.p1 = p1;
  86.         }
  87.         public Point GetP2()
  88.         {
  89.             return p2;
  90.         }
  91.         public void SetP2(Point p2)
  92.         {
  93.             this.p2 = p2;
  94.         }
  95.         public double LineLength()
  96.         // טענת כניסה : הפעולה מקבלת שתי נקודות מטיפוס נקודה.
  97.         // טענת יציאה : הפעולה מחזירה את אורך הקו.
  98.         {
  99.             double length = Math.Sqrt((this.p2.GetX() - p2.GetX()) * (p2.GetX() - p2.GetX()) + (p2.GetY() - p2.GetY()) * (p2.GetY() - p2.GetY()));
  100.             return length;
  101.         }
  102.         public static bool IfMakbil(Point p1 , Point p2)
  103.         {
  104.             if(p1.GetY() == p2.GetY())
  105.             {
  106.                 return true;
  107.             }
  108.             return false;
  109.         }
  110.     }
  111.     //: ///////////////////////////////////////
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement