Baixe o app para aproveitar ainda mais
Prévia do material em texto
using System; public class Ponto { private int x, y; public Ponto(int xValor, int yValor) { this.x = xValor; this.y = yValor; } public Ponto() { x = 0; y = 0; } public string VerificaPontos(Ponto xy) { if(xy.x == this.x && xy.y == this.y) { return "Os pontos são iguais"; } else { return "Os pontos são diferentes"; } } public double Calculo(Ponto xy) { double x = Math.Pow(xy.x - this.x, 2); double y = Math.Pow(xy.y - this.y, 2); return Math.Sqrt(x + y); } } class Program { public static void Main(string[] args) { Ponto p1 = new Ponto(70, 90); Ponto p2 = new Ponto(75, 95); Console.WriteLine("Verificação: " + p1.VerificaPontos(p2)); Console.WriteLine("Distancia: " + p1.Calculo(p2)); Console.ReadLine(); } }
Compartilhar