<pre>import java.util.Random; import java.util.Scanner; public class Main { public static void main(String[] args) { Shape array[] = new Shape[50]; Random rand = new Random(); Scanner eisodos = new Scanner(System.in); int i, rand_num, x, y, sum, p; p = 0; sum = 0; for(i=0; i<50; i++){ rand_num = rand.nextInt(2); if(rand_num == 1){ System.out.println("Δώσε την περίμετρο του κύκλου: "); x = eisodos.nextInt(); while(x<10 || x>50){ System.out.flush(); System.out.println("Δώσε την περίμετρο του κύκλου: "); x = eisodos.nextInt(); } array[i] = new Circle(x); } else { System.out.print("Δώσε την βάση: "); x = eisodos.nextInt(); System.out.print("Δώσε το ύψος: "); y = eisodos.nextInt(); while((x<10 || x >50) || (y<10 || y>50)){ System.out.flush(); System.out.print("Δώσε την βάση: "); x = eisodos.nextInt(); System.out.print("Δώσε το ύψος: "); y = eisodos.nextInt(); } array[i] = new Rectangle(x, y); } } } }
instanceof
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)