So I'm working on a small kinda homework I got... Currently I'm building a small console application using .NET and C#... It is supposed to behave this way:
When the user enters the name of a shape followed by the corresponding number of numeric parameters, define that shape and keep it in memory. The numbers may be of type double. Examples:
circle 1.7 -5.05 6.9 square 3.55 4.1 2.77 rectangle 3.5 2.0 5.6 7.2 triangle 4.5 1 -2.5 -33 23 0.3 donut 4.5 7.8 1.5 1.8
For the circle, the numbers are the x and y coordinates of the centre followed by the radius. For the square it is x and y of one corner followed by the length of the side. For the rectangle it is x and y of one corner followed by the two sides. For the triangle it is the x and y coordinates of the three vertices (six numbers in total). For the donut it is the x and y of the centre followed by the two radiuses.
In addition, every time such a line is entered, the application should give it a unique identifier and print it out in a standardised form, for example:
=> shape 1: circle with centre at (1.7, -5.05) and radius 6.9
That is not really complicated and I know kinda how to do all that... The problem is with some of the calculations the app is supposed to do, which are Math Operations and I don't really remember a lot about how to apply them... For Example:
When the user enters a pair of numbers, the application should print out all the shapes that include that point in the (x, y) space, i.e. it should print out shape X if the given point is inside X. (A point is inside a donut shape if it is inside the outer circle but not inside the inner one.)
It should also print out the surface area of each shape found, and the total area of all the shapes returned for a given point.
So I guess what I'm really asking is help on how to calculate the surface of those shapes with the given parameters, how to calculate the areas (this ones a bit easier to researcher but might as well ask) and lastly how, given a pair of numbers, should I calculate whether or not a certain Shape contains that point in its X and Y space...
Thanks for any help you can give me and have a nice day.