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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

106 Programación I<br />

Ilustración 19 Gastos de la Casa<br />

12.1.2 Clase Casa<br />

El código sería:<br />

package gastosCasa;<br />

public class Casa {<br />

// variables de instancia<br />

private ArrayList conjuntoGastos;<br />

private String direccion;<br />

// Constructor<br />

public Casa() {<br />

conjuntoGastos = new ArrayList();<br />

this.setDireccion("Sin direccion");<br />

}<br />

// acceso y modificacion<br />

public void setDireccion(String unaDireccion) {<br />

direccion = unaDireccion;<br />

}<br />

public String getDireccion() {<br />

return direccion;<br />

}<br />

public void agregarUnGasto(Gasto unGasto) {<br />

this.devolverTodosGastos().add(unGasto);<br />

}<br />

public ArrayList devolverTodosGastos() {<br />

return conjuntoGastos;<br />

}<br />

// devuelve cantidad de elementos<br />

public int cantidadGastos() {<br />

return this.devolverTodosGastos().size();<br />

}

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

Saved successfully!

Ooh no, something went wrong!