using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Figury { public class Wielobok : Figura { protected int ile; protected int IlośćBoków { get { return IlośćBoków; } set { IlośćBoków = value; } } protected Punkt[] w; protected Punkt[] Wierzchołki { get { return w; } } public Wielobok(int i) :base("wielobok") { ile = i; w = new Punkt[i]; } public Wielobok(Punkt[] p) :this(p.Length) { for (int i = 0; i < IlośćBoków; i++) { w[i] = p[i]; } } public override void Obróć(Punkt xy, double kąt) { for (int i = 0; i < ile; i++) w[i].Obróć(xy, kąt); } public override double Pole() { throw new NotImplementedException(); } public override double Obwód() { double ob = 0.0; for (int i = 1; i <= ile ; i++) { ob += DługośćBoku(i); } return ob; } public override void Powiększ(double st) { for (int i = 1; i < ile; i++) { w[i].x = w[0].x + (w[i].x - w[0].x) * st; w[i].y = w[0].y + (w[i].y - w[0].y) * st; } } public override void Przesuń(double dx, double dy) { for (int i = 0; i < ile; i++) { w[i].Przesuń(dx, dy); } } public double DługośćBoku(int i) { return (i != ile) ? w[i - 1].OdległośćOdPunktu(w[i]) : w[ile - 1].OdległośćOdPunktu(w[0]); } public double Kąt(int i) { throw new NotImplementedException(); } public override string ToString() { string s = base.ToString(); foreach (Punkt i in w) { s += i.ToString(); } return s; } } }