- Coordinates, . , , -
public class MySequence {
private AtomicLong currentValue = new AtomicLong(0L);
public long getNextValue() {
return currentValue.getAndIncrement();
}
}
:
new CoordinatePair(mySequence.getNextValue(), x, y);
, , , , Coordinates , . . Coordinate,
public CoordinatePoint {
private long id;
private float x;
private float y;
public CoordinatePoint(long id, float x, float y) {
this.id = id;
this.x = x;
this.y = y;
}
public String toString() {
return "id=" + id + ", (" + x + ", " + y + ")";
}
}
,
public class Example {
public static void main(String ... args) {
MySequence seq = new MySequence();
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter the X Coordinate followed by the return key");
float xCoordinate = keyboard.nextDouble();
System.out.println("Please enter the Y Coordinate followed by the return key");
float yCoordinate = keyboard.nextDouble();
CoordinatePoint c1 = new CoordinatePoint(seq.getNextValue(), xCoordinate, yCoordinate);
System.out.println(c1.toString());
}
}