write point ..circle for this main import java.util.Random; //................ p
ID: 3552961 • Letter: W
Question
write point ..circle for this main
import java.util.Random; //................
public class Main {
public static void main(String[] args) {
Random generator = new Random(); //................
point A=new point(); // call of default const
point B=new point(7,11); // using const with arg
point p=new point();
point q=new point(4,5);
point k=new point(q);
A.setxy(50,25);
A.print();
System.out.println(" the new value of x is "+A.getx() +" and of Y is "+
A.gety());
// an array of points
point []table=new point[10];
// fill it randomly .......
for(int i=0;i<10;i++)
{ table[i]=new point(); ///////////
table[i].setxy(generator.nextInt() % 100,generator.nextInt() %250 );
table[i].print();
}
}
}
Explanation / Answer
import java.util.Random; // library import for random function. used for random generator.
public class Main {
public static void main(String[] args) {
Random generator = new Random(); //creating a object genearator of random type.now it can inherit all the functions //random class
point A=new point(); // call of default const
point B=new point(7,11); // using const with arg
point p=new point();
point q=new point(4,5);
point k=new point(q);
A.setxy(50,25);
A.print();
System.out.println(" the new value of x is "+A.getx() +" and of Y is "+
A.gety());
// an array of points
point []table=new point[10];
// fill it randomly .......
for(int i=0;i<10;i++)
{ table[i]=new point(); ///////////
table[i].setxy(generator.nextInt() % 100,generator.nextInt() %250 );
table[i].print();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.