Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package kursovrchernyak;
- /**
- *
- * @author paul
- */
- import java.util.Random;
- class MyPoint {
- int x, y;
- static Random random = new Random();
- MyPoint(int xx, int yy) { // Constractor
- x=xx;
- y=yy;
- }
- public MyPoint() { // Constractor
- this(random.nextInt(), random.nextInt());
- }
- public int getX() {return x;}
- public int getY() {return y;}
- public boolean isEqual(MyPoint p) {
- return this.getX() == p.getX() && this.getY() == p.getY();
- }
- /** Create array of random points. */
- public static MyPoint[] newArray(int len) {
- MyPoint[] arr = new MyPoint[len];
- for(int i=0; i < arr.length; i++) {
- arr[i] = new MyPoint();
- }
- return arr;
- }
- /** Create array of random points (x=y) sorted by x */
- public static MyPoint[] newSortedArray(int len) {
- MyPoint[] arr = new MyPoint[len];
- for(int i=0, a=0; i < arr.length; i++) {
- a += random.nextInt();
- arr[i] = new MyPoint(a,a);
- }
- return arr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement