Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- class SetCord
- {
- public int x;
- public int y;
- private int Id;
- private static int nextId = 1;
- public SetCord(int a, int b)
- {
- x=a;
- y=b;
- }
- public int getX()
- {
- Id=nextId;
- nextId++;
- return x;
- }
- public int getY()
- {
- Id=nextId;
- nextId++;
- return y;
- }
- public int getId()
- {
- return Id;
- }
- }
- class Test{
- public static void main(String args[])
- {
- Random rand = new Random();
- SetCord[] teste = new SetCord[3];
- for (int i = 0; i < 3; i++)
- {
- teste[i] = new SetCord(rand.nextInt(100), rand.nextInt(35));
- }
- for(SetCord x:teste)
- {
- System.out.println("x = " + x.getX());
- System.out.println("y = " + y.getY()); //blad kompilacj - y cannot be resolved
- System.out.println("x id " + x.getId());
- System.out.println("y id " + y.getId()); //blad kompilacj - y cannot be resolved
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement