Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

Commit 79ba662

Browse files
committed
Subiendo implementación que recuerdo (con ajustes) del primer recuperatorio
1 parent c67fa8b commit 79ba662

25 files changed

+409
-0
lines changed

ParcialFecha2/.classpath

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
27+
<attributes>
28+
<attribute name="maven.pomderived" value="true"/>
29+
<attribute name="optional" value="true"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
33+
<attributes>
34+
<attribute name="maven.pomderived" value="true"/>
35+
<attribute name="test" value="true"/>
36+
<attribute name="optional" value="true"/>
37+
</attributes>
38+
</classpathentry>
39+
<classpathentry kind="output" path="target/classes"/>
40+
</classpath>

ParcialFecha2/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>oo1_archetype</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8
4+
encoding/<project>=UTF-8
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
3+
org.eclipse.jdt.core.compiler.compliance=11
4+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7+
org.eclipse.jdt.core.compiler.release=disabled
8+
org.eclipse.jdt.core.compiler.source=11
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

ParcialFecha2/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>ar.edu.unlp.info.oo1</groupId>
6+
<artifactId>ParcialFecha2</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<name>ParcialFecha2</name>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
15+
</properties>
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-surefire-plugin</artifactId>
21+
<version>2.22.2</version>
22+
</plugin>
23+
</plugins>
24+
</build>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.junit.jupiter</groupId>
29+
<artifactId>junit-jupiter-engine</artifactId>
30+
<version>5.7.2</version>
31+
<scope>test</scope>
32+
</dependency>
33+
34+
</dependencies>
35+
36+
37+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ar.edu.unlp.info.oo1.ParcialFecha2;
2+
3+
public class ConsultaMedica extends ServicioIntervenido{
4+
5+
public ConsultaMedica(Medico medico) {
6+
super(medico);
7+
}
8+
9+
public double costo() {
10+
return this.medico.getHonorarios() + this.adicionalPorDomingo() + 300 + medico.adicionalPorAntiguedad();
11+
}
12+
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package ar.edu.unlp.info.oo1.ParcialFecha2;
2+
3+
import java.time.LocalDate;
4+
5+
public class Guarderia implements Servicio{
6+
7+
private Mascota mascota;
8+
private int dias;
9+
private LocalDate fecha;
10+
11+
public Guarderia(Mascota mascota, int dias) {
12+
this.mascota = mascota;
13+
this.dias = dias;
14+
this.fecha = LocalDate.now();
15+
}
16+
17+
public double costo() {
18+
return dias*500*mascota.descuentoPorServicios();
19+
}
20+
21+
public LocalDate getFecha() {
22+
return this.fecha;
23+
}
24+
25+
public boolean enFecha(LocalDate fecha) {
26+
return this.fecha.isAfter(fecha) && this.fecha.isBefore(fecha.plusDays(dias)); // aca realmente tengo dudas de si contempla los valores de borde (día de inicio, día de fin) o sólo el rango entre ellos
27+
}
28+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package ar.edu.unlp.info.oo1.ParcialFecha2;
2+
3+
import java.time.LocalDate;
4+
import java.time.Period;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
public class Mascota {
9+
10+
private String nombre;
11+
private LocalDate fechaDeNacimiento;
12+
private String especie;
13+
private List<Servicio> servicios;
14+
15+
public Mascota(String nombre, LocalDate nacimiento, String especie) {
16+
this.nombre = nombre;
17+
this.fechaDeNacimiento = nacimiento;
18+
this.especie = especie;
19+
this.servicios = new ArrayList<Servicio>();
20+
}
21+
22+
public Servicio registrarConsultaMedica(Medico medico) {
23+
Servicio servicio = new ConsultaMedica(medico);
24+
this.servicios.add(servicio);
25+
return servicio;
26+
}
27+
28+
public Servicio registrarVacunacion(Medico medico, String nombre, double costo) {
29+
Servicio servicio = new Vacunacion(medico, nombre, costo);
30+
this.servicios.add(servicio);
31+
return servicio;
32+
}
33+
34+
public Servicio registrarGuarderia(int dias) {
35+
Servicio servicio = new Guarderia(this, dias);
36+
this.servicios.add(servicio);
37+
return servicio;
38+
}
39+
40+
public double costoTotalPorFecha(LocalDate fecha) {
41+
return servicios.stream()
42+
//.filter(servicio -> servicio.getFecha() == fecha)
43+
.filter(servicio -> servicio.enFecha(fecha) == true)
44+
.mapToDouble(servicio -> servicio.costo())
45+
.sum();
46+
}
47+
48+
public int getEdad() {
49+
return Period.between(fechaDeNacimiento, LocalDate.now()).getYears();
50+
}
51+
52+
public int cantidadServicios() {
53+
return this.servicios.size();
54+
}
55+
56+
public double descuentoPorServicios() {
57+
if (this.cantidadServicios() >= 5) {
58+
return 0.9; // aplica el 10%
59+
} else {
60+
return 1.0; // paga el total
61+
}
62+
}
63+
64+
public boolean esCachorro() {
65+
return this.getEdad() < 2;
66+
}
67+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ar.edu.unlp.info.oo1.ParcialFecha2;
2+
3+
import java.time.LocalDate;
4+
import java.time.Period;
5+
6+
public class Medico {
7+
8+
private String nombre;
9+
private LocalDate fechaDeIngreso;
10+
private double honorarios;
11+
12+
public Medico (String nombre, LocalDate ingreso, double honorarios) {
13+
this.nombre = nombre;
14+
this.fechaDeIngreso = ingreso;
15+
this.honorarios = honorarios;
16+
}
17+
18+
public LocalDate getFechaDeIngreso() {
19+
return fechaDeIngreso;
20+
}
21+
22+
public double getHonorarios() {
23+
return honorarios;
24+
}
25+
26+
public double adicionalPorAntiguedad() {
27+
return 100*Period.between(fechaDeIngreso, LocalDate.now()).getYears();
28+
}
29+
}

0 commit comments

Comments
 (0)