-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCiudad.java
More file actions
33 lines (26 loc) · 947 Bytes
/
Ciudad.java
File metadata and controls
33 lines (26 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package ministerioGeografia;
public class Ciudad implements IGeneradorInformacion{
private String nombre;
private int habitantes;
private double superficie;
private int habitantes2030;
private double superficieOcupada;
public Ciudad(String nombre, int habitantes, double superficie) {
this.nombre = nombre;
this.habitantes = habitantes;
this.superficie = superficie;
}
@Override
public void generarInformacion() {
this.habitantes2030 = (int) (habitantes * 0.90);
this.superficieOcupada = superficie + 10000;
}
@Override
public String toString() {
return String.format("Ciudad: %s\nCantidad de habitantes: %d\nSuperficie: %.2f\nProyección habitantes 2030: %d\nSuperficie ocupada: %.2f\n",
nombre, habitantes, superficie, habitantes2030, superficieOcupada);
}
public String getNombre() {
return nombre;
}
}