//по координатам прямоугольника строит список состоящий из фигур с теми же координатами public FigureList CreateByRectangleCoordinates(Figure rectangle) { if (rectangle.Type != 1) { throw new ArgumentException(); } Random rnd = new Random(); MyList = new FigureList(); while (MyList.Count() < 6) { int item = rnd.Next(2, 4); if (item == 3) { MyList.AddLast(new Figure(item, rectangle.XLU, rectangle.YLU, Math.Abs(rectangle.XRD - rectangle.XLU), 0, rnd.Next(1, 4))); } else { MyList.AddLast(new Figure(item, rectangle.XLU, rectangle.YLU, rnd.Next(1, 10), rnd.Next(1, 10), rnd.Next(1, 4))); } } return(MyList); }
//строит список фигур, площадь которых больше некоторой константы public FigureList BuildListByConst(int constant) { MyList = new FigureList(); Random rnd = new Random(); while (MyList.Count() < 5) { int type = rnd.Next(1, 4); if (type == 1) { int x1 = rnd.Next(0, 25); int y1 = rnd.Next(0, 25); int x2 = rnd.Next(25, 50); int y2 = rnd.Next(25, 50); if (y2 - y1 > constant || x2 - x1 > constant) { MyList.AddByIndex(new Figure(type, x1, y1, x2, y2, rnd.Next(1, 8)), 0); } } if (type == 3) { int x1 = rnd.Next(0, 25); int y1 = rnd.Next(0, 25); int x2 = rnd.Next(0, 15); if (x2 * 6 > constant) { MyList.AddByIndex(new Figure(type, x1, y1, x2, 0, rnd.Next(1, 8)), 0); } } } return(MyList); }