-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sibogatov Rinat #221
base: master
Are you sure you want to change the base?
Sibogatov Rinat #221
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом решение хорошее, осталось только немного доработать
@@ -0,0 +1,39 @@ | |||
using System.Drawing; | |||
|
|||
namespace TagsCloudVizualization; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cs/TagsCloudVizualization/Program.cs
Outdated
return new CircularCloudLayouter(center); | ||
} | ||
|
||
private static void GenerateRandomRectangles(CircularCloudLayouter layouter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По названию метода ожидается, что он вернет прямоугольники
@@ -0,0 +1,47 @@ | |||
using System.Drawing; | |||
|
|||
namespace TagsCloudVizualization; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
{ | ||
private readonly Point center; | ||
private readonly List<Rectangle> rectangles; | ||
private readonly Spiral spiral; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Assert.DoesNotThrow(() => new CircularCloudLayouter(center)); | ||
} | ||
|
||
[TestCase(-4, 16, TestName = "PutNextRectangle_WidthNotPositive_ThrowsArgumentException")] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
namespace TagsCloudVizualizationTests; | ||
|
||
public class CircularCloudLayouterTests |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
private readonly Point center; | ||
private readonly List<Rectangle> rectangles; | ||
private readonly Spiral spiral; | ||
private readonly IEnumerator<Point> spiralPointsEnumerator; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
private double radius; | ||
private double angle; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
} | ||
|
||
public static Point ConvertFromPolarToCartesian(double angle, double radius) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
namespace TagsCloudVizualizationTests; | ||
|
||
public class CircularCloudLayouterTests |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не забывай, пожалуйста, реформатить код перед сдачей, так его будет гораздо проще проверять
return false; | ||
} | ||
|
||
private bool RectanglesIntersect(Rectangle first, Rectangle second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
думаю, что перебор выносить метод в одну строчку в данном случае
var intersectedPairsCount = rectangles | ||
.SelectMany((rect1, index1) => rectangles.Skip(index1 + 1) | ||
.Select(rect2 => rect1.IntersectsWith(rect2))) | ||
.Count(isIntersected => isIntersected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что-то не очень поняла, получается, что есть прямоугольники, которые пересекаются? кажется, такого быть не должно...
|
||
GenerateRectangles(layouter, rectangleSize, rectanglesCount); | ||
|
||
CheckDensity(layouter.Rectangles).Should().BeTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Плотность можно проверить, например, так:
Найти радиус круга, в который вписаны прямоугольники (расстояние от центра до самой удаленной вершины прямоугольника), посчитать отношение суммарной площади прямоугольников к площади этого круга
@elis_shtol