Дечки,
Ми треба помош за задачава, треба за 3 часа да биде готова
Значи:
Development Task
We have a set of shapes stored in a txt file (circles, triangles and quadrilateral), one shape in each line. The shapes are defined by points, and the points are defined by coordinates (in two-dimensional space, the unit is a pixel). The coordinates are separated by a comma (',') and the points are separated by a semicolon (';').
A line may contain two, three or four points:
Write a program that parses a txt file having this format and creates objects from the detected shapes.
There have to be three classes (at least): Circle, Triangle and Quadrilateral. All three classes must have a getArea() instance method. Points defining a shape should be sent to the constructor and stored in private datafields.
For each type of shape, the script has to find the one with the maximum and minimum area.
It also needs to find the one shape (from all), that has an area closest to the average of the maximum and minimum area values (so the average of: min(Circles), max(Circles), min(Triangles), max(Triangles), min(Quadrilateral), max(Quadrilateral)).
Notes:
It is useful to declare a function that returns the distance between two points.
This can be done using the Pythagorean theorem.
The area of the triangle can be calculated from the side lengths using Heron's formula:
https://secure.wikimedia.org/wikipedia/en/wiki/Heron's_formula
The area of a quadrilateral ABCD can be calculated using vectors.
Let vectors AC and BD form the diagonals from A to C and from B to D.
AC vector has coordinates (x1, y1), and BD vector has coordinates (x2, y2).
The area of the quadrilateral is then: 1/2*|x1*y2 - x2*y1|
https://secure.wikimedia.org/wikipedia/en/wiki/Quadrilateral#Area_of_a_convex_quadrilateral