Do you understand this? I have added some comments of my own iunderstanding, but i would be grateful someone could justify it?
Code:
public int levelbottom(int v)
//0->0, 1->6, 2->11, 3->15, 4->18, 5->20, 6->21
{return (21 - ((6-v)*(7-v))/2);
}
public boolean better(int a, int b, int c)
//Is c closer to a than b is to a?
{return (((b<c) && (b-a<a-c)) || ((c<b) && (a-c<b-a)));
}
public int calc(int h, int l, int f)
//doing the calculation?
{switch (f)
{case 0: return h+l; // addition
case 1: return h-l; // subtraction
case 2: return h*l; // multiplication
case 3: return h/l; // division
default:
}
return 0; // should not arrive here?