codice:
import java.util.ArrayList;
import java.util.Random;

public class Corriere {

	
	public static void main(String[] args) {
		
		ArrayList<Spedizioni> sped = new ArrayList<Spedizioni>();
		
		int cid;
		
		for (int i=0; i<1000;i++){
			
			Random rnd = new Random();
		int tipo = rnd.nextInt(3);
		//destinazione
		String dest = Integer.toString(rnd.nextInt(100));
			
		
		switch (tipo){
		case 0:
			 cid = rnd.nextInt(2000);
			double pes = (double)rnd.nextInt(300);
			sped.add(new Casse(cid, dest, pes));
		break;
		
		case 1:
			 cid = rnd.nextInt(2000);
			float x = (float)rnd.nextInt(20);
			float y = (float)rnd.nextInt(20);
			float z = (float)rnd.nextInt(20);
			
			sped.add(new Scatole(cid, dest, x, y, z));
		break;	
	
		case 2:
			 cid = rnd.nextInt(2000);
			boolean exp = rnd.nextBoolean();
			sped.add(new Buste(cid, dest, exp));
		break;
		}
		}
		
		

			for (Spedizioni e : sped){
			System.out.println(e.getCodiceID());
					
				
				
				}}
			
	
		
	}

da come si legge c'è una superclasse Spedizioni con figli Casse, Scatole e Buste
come posso stampare il codice ID (cid) di tutte e 1000 le spedizioni?
il for each su arrayList funziona?così com'è non funziona niente..dv ho sbagliato?

psvviamente il metodo getcodiceID non ha altro che ritornare l'argomento richiesto.