Really need help with this one. I'm writing a program to simulate a Risk game and I need to write a method to make two countries neighbors, which would be done by adding each the neighbor country to each country's neighbor's array. To do this, I will need to click on the country, click on the map and then click on the other country. My method gets the country's name but how do I tell it to wait for a mouse click before trying to get the second country's name???? I've tried everything but to no avail. Any help would be appreciated.
[CODE=java]public void addNeighbor(Cou ntry country) {
boolean exists, click;
Country tempCountry;
tempCountry = searchCountry(r ed, green, blue);
if (country == tempCountry){
JOptionPane.sho wMessageDialog( null, "Error: Territories are the same. Please try again");
}
else {
exists = country.borderE xists(tempCount ry);
if (exists){
JOptionPane.sho wMessageDialog( null, "Error: Territories are already borders.");
}
else {
country.addBord erArray(tempCou ntry);
tempCountry.add BorderArray(cou ntry);
JOptionPane.sho wMessageDialog( null, "Border successfull added.");
}
}
}[/CODE]
[CODE=java]public void addNeighbor(Cou ntry country) {
boolean exists, click;
Country tempCountry;
tempCountry = searchCountry(r ed, green, blue);
if (country == tempCountry){
JOptionPane.sho wMessageDialog( null, "Error: Territories are the same. Please try again");
}
else {
exists = country.borderE xists(tempCount ry);
if (exists){
JOptionPane.sho wMessageDialog( null, "Error: Territories are already borders.");
}
else {
country.addBord erArray(tempCou ntry);
tempCountry.add BorderArray(cou ntry);
JOptionPane.sho wMessageDialog( null, "Border successfull added.");
}
}
}[/CODE]
Comment