I hope someone could help me to simplify this expression. As shown below there are 2 values that will be checked. Acoording to both of these values, I have to update an image. I tried some stuff but everything leads back to this long if else statement I am not sure whether this has been asked before since I am not sure what to search for. If you could provide me some known previous question would be helpful too. I have value x and y which represent the position of a gps receiver from the center of a car. And depending on this position, I have to update the position of the gps in the image shown to the user.
if (val > 0)
{
if (secondVal > 0)
{
SetIcon("right_front.png")
}
else if (secondVal< 0)
{
SetIcon("right_back.png")
}
else
{
SetIcon("right_center.png")
}
}
else if (val < 0)
{
if (secondVal > 0)
{
SetIcon("left_front.png")
}
else if (secondVal < 0)
{
SetIcon("left_back.png")
}
else
{
SetIcon("left_center.png")
}
}
else
{
if (secondVal > 0)
{
SetIcon("center_front.png")
}
else if (secondVal < 0)
{
SetIcon("center_back.png")
}
else
{
SetIcon("center_center.png")
}
}