-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
938dbe2
commit ef8f696
Showing
10 changed files
with
200 additions
and
74 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
...ain/java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/Cilindro.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
public class Cilindro extends Pieza{ | ||
private int radio; | ||
private int altura; | ||
|
||
public Cilindro(int radio, int altura, String material, String color) { | ||
super(material,color); | ||
this.radio=radio; | ||
this.altura=altura; | ||
} | ||
|
||
public double getVolumen(){ | ||
return (int) Math.round(Math.PI*(Math.pow(this.radio,2))*this.altura); | ||
} | ||
public double getSuperficie(){ | ||
return (int) Math.round(2*Math.PI*this.radio*this.altura+2*Math.PI*Math.pow(this.radio,2)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../main/java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/Esfera.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
public class Esfera extends Pieza{ | ||
private int radio; | ||
|
||
public Esfera(int r, String m, String c) { | ||
super(m,c); | ||
this.radio = r; | ||
} | ||
|
||
public int getRadio() { | ||
return radio; | ||
} | ||
|
||
public void setRadio(int radio) { | ||
this.radio = radio; | ||
} | ||
|
||
public double getVolumen() { | ||
return 1.33333333333 * Math.PI * Math.pow(this.getRadio(), 3); | ||
} | ||
|
||
public double getSuperficie() { | ||
return 4 * Math.PI * Math.pow(radio, 2); | ||
} | ||
|
||
} |
41 changes: 0 additions & 41 deletions
41
...main/java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/Persona.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...c/main/java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/Pieza.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
public abstract class Pieza { | ||
private String material; | ||
private String color; | ||
|
||
public String getMaterial() { | ||
return material; | ||
} | ||
public void setMaterial(String material) { | ||
this.material = material; | ||
} | ||
public String getColor() { | ||
return color; | ||
} | ||
public void setColor(String color) { | ||
this.color = color; | ||
} | ||
public Pieza(String material, String color) { | ||
this.material = material; | ||
this.color = color; | ||
} | ||
|
||
public abstract double getVolumen(); | ||
public abstract double getSuperficie(); | ||
} |
42 changes: 42 additions & 0 deletions
42
...ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/PrismaRectangular.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
public class PrismaRectangular extends Pieza{ | ||
private int ladoMayor; | ||
private int ladoMenor; | ||
private int altura; | ||
|
||
public PrismaRectangular(int lMa, int lMe, int h, String m, String c) { | ||
super(m,c); | ||
this.ladoMayor = lMa; | ||
this.ladoMenor = lMe; | ||
this.altura = h; | ||
} | ||
|
||
public int getLadoMayor() { | ||
return ladoMayor; | ||
} | ||
public void setLadoMayor(int ladoMayor) { | ||
this.ladoMayor = ladoMayor; | ||
} | ||
public int getLadoMenor() { | ||
return ladoMenor; | ||
} | ||
public void setLadoMenor(int ladoMenor) { | ||
this.ladoMenor = ladoMenor; | ||
} | ||
public int getAltura() { | ||
return altura; | ||
} | ||
public void setAltura(int altura) { | ||
this.altura = altura; | ||
} | ||
|
||
public double getVolumen() { | ||
return this.getLadoMayor() * this.getLadoMenor() * this.getAltura(); | ||
} | ||
|
||
public double getSuperficie() { | ||
return 2 * (ladoMayor * ladoMenor + ladoMayor * altura + ladoMenor * altura); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...du/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/ReporteDeConstruccion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ReporteDeConstruccion { | ||
private List<Pieza> piezas; | ||
|
||
public ReporteDeConstruccion() { | ||
this.piezas = new ArrayList<Pieza>(); | ||
} | ||
|
||
public void addPieza(Pieza pieza) { | ||
this.piezas.add(pieza); | ||
} | ||
|
||
public double getVolumenDeMaterial(String material) { | ||
return this.piezas.stream() | ||
.filter(p -> p.getMaterial().equals(material)) | ||
.mapToDouble(p -> p.getVolumen()) | ||
.sum(); | ||
} | ||
|
||
public double getSuperficieDeColor(String color) { | ||
return this.piezas.stream() | ||
.filter(p -> p.getColor().equals(color)) | ||
.mapToDouble(p -> p.getSuperficie()) | ||
.sum(); | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
.../java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/PersonaTest.java
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...t/java/ar/edu/unlp/info/oo1/Ejercicio_12_Volumen_y_superficie_con_solidos/PiezasTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package ar.edu.unlp.info.oo1.Ejercicio_12_Volumen_y_superficie_con_solidos; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDate; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PiezasTest { | ||
|
||
ReporteDeConstruccion reporte; | ||
Cilindro cilindro; | ||
Esfera esfera; | ||
PrismaRectangular prisma; | ||
|
||
private void initialize() { | ||
reporte = new ReporteDeConstruccion(); | ||
cilindro = new Cilindro(10,20,"Hierro","Rojo"); | ||
esfera = new Esfera(8,"Hierro","Azul"); | ||
prisma = new PrismaRectangular(10,5,30,"Metal","Azul"); | ||
} | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
this.initialize(); | ||
} | ||
|
||
@Test | ||
public void testInicial() { | ||
assertEquals(6283.185,cilindro.getVolumen(),1e-3); | ||
assertEquals(1884.955,cilindro.getSuperficie(),1e-3); | ||
assertEquals(2144.660,esfera.getVolumen(),1e-3); | ||
assertEquals(804.247,esfera.getSuperficie(),1e-3); | ||
assertEquals(1500,prisma.getVolumen()); | ||
assertEquals(1000,prisma.getSuperficie()); | ||
} | ||
|
||
@Test | ||
void testReportes() { | ||
reporte.addPieza(cilindro); reporte.addPieza(esfera); | ||
reporte.addPieza(prisma); | ||
assertEquals(8427.845,reporte.getVolumenDeMaterial("Hierro"),1e-3); | ||
assertEquals(1500,reporte.getVolumenDeMaterial("Metal")); | ||
assertEquals(1884.955,reporte.getSuperficieDeColor("Rojo"),1e-3); | ||
assertEquals(1804.247,reporte.getSuperficieDeColor("Azul"),1e-3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters