10.05.2014 Views

programación i - Universidad ORT Uruguay

programación i - Universidad ORT Uruguay

programación i - Universidad ORT Uruguay

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

160 Programación I<br />

}<br />

}<br />

import java.util.*;<br />

public class ColeccionCD {<br />

private ArrayList coleccionCD;<br />

public ColeccionCD() {<br />

coleccionCD = new ArrayList();<br />

}<br />

public void agregarCD(CD unCD) {<br />

this.getColeccionCD().add(unCD);<br />

}<br />

public ArrayList listarTodos() {<br />

return getColeccionCD();<br />

}<br />

public ArrayList getColeccionCD() {<br />

return coleccionCD;<br />

}<br />

public boolean existeCD(String unTitulo) {<br />

CD unCD = new CD();<br />

unCD.setTitulo(unTitulo);<br />

return this.getColeccionCD().contains(unCD);<br />

}<br />

public void eliminarCD(CD unCD) {<br />

this.getColeccionCD().remove(unCD);<br />

}<br />

}<br />

public ArrayList ordenar() {<br />

Collections.sort(this.coleccionCD);<br />

return this.getColeccionCD();<br />

}<br />

public class PruebaColeccionCD {<br />

public static void main(String[] args) {<br />

ColeccionCD miColeccion;<br />

CD cd1, cd2, cd3;<br />

miColeccion = new ColeccionCD();<br />

cd1 = new CD("Mocedades 20 años", 11);<br />

cd2 = new CD("The Wall", 21);<br />

cd3 = new CD("Perales", 183);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!