I have a java exercise follow: there are n machines of 3 type A,B,C, each machine has coordinates (x,y) and operate radius, with data get from a XML file, for instance:
<machine>
<number ="1">
<type>C</type>
<cox>40</cox>
<coy>80</coy>
<rad>30</rad>
</number>
<number ="2">
<type>A</type>
<cox>25</cox>
<coy>35</coy>
<rad>40</rad>
</number>
<number ="3">
<type>C</type>
<cox>50</cox>
<coy>10</coy>
<rad>50</rad>
</number>
</machine>
I made 3 class A, B, C and already got information from xml file. But the 2 problems is that:
calculate the distance between each machine
add them to list of each machine if distance is less than radius.
I known the formula to calculate the distance but dont know how to get x, y to calculate nx(n-1) distances, and add them to list. Could anyone give me the idea to solve these 2 problems? Thank so much!