using System; using System.Collections.Generic; using System.Text; namespace meetodiasendused { class Punkt { protected int x; protected int y; public Punkt(int ux, int uy) { this.x = ux; this.y = uy; } public virtual double KaugusNullist() { return Math.Sqrt(x * x + y * y); } public string TeataAndmed() { return "x=" + x + " y=" + y; } } class RuumiPunkt : Punkt { protected int z; public RuumiPunkt(int ux, int uy, int uz):base(ux, uy) { this.z = uz; } public override double KaugusNullist() { return Math.Sqrt(x*x+y*y+z*z); } new public void TeataAndmed() { Console.WriteLine("x={0}, y={1}, z={2}", x, y, z); } } class Program { static void Main(string[] args) { Punkt p1 = new Punkt(3, 5); Console.WriteLine(p1.TeataAndmed() + " kaugus:" + p1.KaugusNullist()); Punkt p2 = new RuumiPunkt(1, 2, 3); Console.WriteLine(p2.TeataAndmed() + " kaugus:" + p2.KaugusNullist()); RuumiPunkt p3 = new RuumiPunkt(1, 2, 3); p3.TeataAndmed(); Console.WriteLine(" kaugus:" + p3.KaugusNullist()); } } }