Added setStateToInRequirement that I forgot earlier

This commit is contained in:
Tomáš Musil 2020-12-27 19:11:07 +01:00
parent 1771fc0fdb
commit 4fba75b0e1

View File

@ -84,14 +84,14 @@ public class Product
} }
/** /**
* Set current product state to READY_FOR_DISPATCH. Throws IllegalStateException if the product is not AVAILABLE. * Set current product state to READY_FOR_DISPATCH. Throws IllegalStateException if the product is not IN_REQUIREMENT.
*/ */
public void setStateToReadyForDispatch() public void setStateToReadyForDispatch()
{ {
if(this.productState.equals(ProductState.AVAILABLE)) if(this.productState.equals(ProductState.IN_REQUIREMENT))
this.productState = ProductState.READY_FOR_DISPATCH; this.productState = ProductState.READY_FOR_DISPATCH;
else else
throw new IllegalStateException("Cannot set state READY_FOR_DISPATCH. Product is not AVAILABLE!"); throw new IllegalStateException("Cannot set state READY_FOR_DISPATCH. Product is not IN_REQUIREMENT!");
} }
/** /**
@ -127,6 +127,17 @@ public class Product
throw new IllegalStateException("Cannot set state IN_ACTION. Product is not AVAILABLE!"); throw new IllegalStateException("Cannot set state IN_ACTION. Product is not AVAILABLE!");
} }
/**
* Set current product state to IN_REQUIREMENT. Throws IllegalStateException if the product is not AVAILABLE.
*/
public void setStateToInRequirement()
{
if(this.productState.equals(ProductState.AVAILABLE))
this.productState = ProductState.IN_REQUIREMENT;
else
throw new IllegalStateException("Cannot set state IN_REQUIREMENT. Product is not AVAILABLE!");
}
/* /*
public void setProductState(ProductState productState) public void setProductState(ProductState productState)
{ {