Skip to content

Commit

Permalink
fix(qmp): constructors call order
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasanchez committed Apr 23, 2021
1 parent a7a576b commit 051d9a2
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions 01-lecture/quemepongo/src/main/java/quemepongo/Prenda.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @author Tomás Sánchez
* @since 04.21.2021
* @version 1.1
* @version 1.2
*/
public class Prenda {

Expand All @@ -28,9 +28,9 @@ public class Prenda {
/**
* El color secundario
*
* @since 1.0
* @since 1.1
*/
public Color color2 = Color.NINGUNO;
public Color color2;

/**
* El material con que está hecho la prenda
Expand All @@ -55,16 +55,10 @@ public Categoria categoria() {
* @param principal - el color principal
* @param matnr - el material con el que está hecha
* @author Tomás Sánchez
* @since 1.1
* @since 1.2
*/
public Prenda(TipoPrenda tipoPrenda, Color principal, Material matnr) {

if (Objects.isNull(principal) || Objects.isNull(tipoPrenda) || Objects.isNull(matnr))
throw new IllegalArgumentException("El tipo, color principal y material son obligatorios");

tipo = tipoPrenda;
color1 = principal;
material = matnr;
this(tipoPrenda, principal, null, matnr);
}

/**
Expand All @@ -75,10 +69,15 @@ public Prenda(TipoPrenda tipoPrenda, Color principal, Material matnr) {
* @param secundario - el color secundario
* @param matnr - el material con el que está hecha
* @author Tomás Sánchez
* @since 1.1
* @since 1.2
*/
public Prenda(TipoPrenda tipoPrenda, Color principal, Color secundario, Material matnr) {
this(tipoPrenda, principal, matnr);
if (Objects.isNull(principal) || Objects.isNull(tipoPrenda) || Objects.isNull(matnr))
throw new IllegalArgumentException("El tipo, color principal y material son obligatorios");

tipo = tipoPrenda;
color1 = principal;
material = matnr;
color2 = secundario;
}

Expand Down

0 comments on commit 051d9a2

Please sign in to comment.