Post

• NA
• 342
• 49.1k

# C#

Aug 2 2015 4:12 AM
The exercise consists in creating a fully functional method/function to sort a set of squares
one next to the other in increasing size order along the X axis .
The project has to be developed using C #, no other language is allowed. Try to make the
method/function as professional as possible (proper comments, perfect indentation, meaningful
variable names...) as it’s not a lab practical, it’s a professional development. Pay extreme
attention to t he details and the readability and simplicity o f the code. Use auxiliary
methods as required or deemed appropriate for a better structure and isolation and less
coupling.
public static void OrganiseSquares ( ref List <Square> pio_Squares)
Method description:
The method OrganiseSquares gets a list of squares and modifies each square position so the
squares are placed one next to the other in increasing size order along the X axis.
Parameter description:
pio_Squares: The list of squares as input and output. For the output the squares should be sorted
from smaller to bigger and in the right position. All the squares are in position 0,0 initially.
return: The return value will be void a s the imputed Square objects will be modified to set their
position according to the algorithm. There must not be any space between squares.
The class Square is as follows:

using System.Collections.Generic;
internal class Square
{
private double m_S ;
private double m_PX = 0 ;
private double m_PY = 0 ;
public Square ( double p_S )
{
m_S = p_S ;
}
public void SetXPosition ( double p_PX )
{
m_PX = p_PX ;
}
public void SetYPosition ( double p_PY )
{
m_PY = p_PY ;
}
public double GetSide ()
{
return m_S ;
}
public static void OrganiseSquares ( ref List <Square> pio_Squares)
{