So basically for a school project I have to solve the following problem by writing a Java application.
It is about 3 soldiers: C, H and L. All are plotted on a 2D graph randomly where 0=
The winner will be the last soldier remaining on the battlefield. When a soldier dies, he gets taken off the graph, so his position becomes (-1,-1) besides for C, he stays in the same position even if he is dead. Also, if one soldier kills another, the murderer takes the dead soldier's position on the battlefield (graph), so the coordinates change.
The program needs to print the winner, along when every time a soldier dies (e.g. "C has been killed by H", "H has been killed by L", "L is victorious").
My way of starting this problem has been by creating 2 classes (one for the soldiers and their attributes and the other showing the battlefield). The school recommends we import: 'java.awt.geom.Point2D' for the battlefield and coordinates and 'java.util.Random' to create the random coordinates for putting the soldiers on the field. I'm assuming an algorithm needs to be written to work out which soldier would reach to the other the quickest and which one survives.
However now I am very stuck and have no clue where to go after assigning String names and double values to each soldier variable. Please help!
Aucun commentaire:
Enregistrer un commentaire