Results 1 to 4 of 4
Thread: arryalist, while loop
- 03-08-2009, 06:34 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
arryalist, while loop
Hi, I have a problem with a program I´m writing.
I want the program to ´ask´ the user to input 10 sets of coordinates (so 2 integers per set).
For this I´ve made an arraylist to which I would like to add the sets of coordinates which have been entered by the user.
The while loop should ask the players 10 times to input that set of coordinates and add each input to the next ite, in the arraylist.
Can you guys tell me what I do wrong?
Thanks to anyone who can help.
Code of program
import seabattle .*;
import java.util.ArrayList;
/**
* Write a description of class Zeeslag here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Zeeslag
{
private String player1;
private String player2;
Gui gui = new Gui(10 , 10);
private int[] aantalSchepen;
/**
* constructor
*/
public Zeeslag(String speler1, String speler2)
{
player1 = speler1;
player2 = speler2;
ArrayList aantalSchepen = new ArrayList();
}
/**
* methodes
*/
public void botenInvoeren(int x, int y)
{
int index = 0;
gui.start();
while(index < 10)
{
aantalSchepen.add(new Position(index, (x,y) ));
index++;
}
}
}
- 03-08-2009, 06:51 PM #2
Telling the forum what the problem you're seeing would help. What does it not do? Do you get compile errors? Wrong output? The more information you place about the problem you're seeing with your code, the more specific help you can get.
Question: Where does the user input the information into the program?
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-08-2009, 07:09 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
One of the problems is that I want to put a couple of coordinates (x, y) in an Arraylist, and I don't know how to do this.
I' ve added a screenshot which shows the error.
-
Similar Threads
-
for loop help
By soc86 in forum New To JavaReplies: 9Last Post: 01-24-2011, 09:45 PM -
While loop
By verbazon in forum New To JavaReplies: 5Last Post: 02-25-2009, 01:29 AM -
Need help with a loop
By ReV13 in forum New To JavaReplies: 15Last Post: 12-01-2008, 04:48 PM -
For Loop
By kian_hong2000 in forum New To JavaReplies: 1Last Post: 08-07-2008, 02:01 PM -
can you help me with this for loop?
By java_fun2007 in forum New To JavaReplies: 6Last Post: 12-22-2007, 10:20 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks