@@ -18,20 +18,19 @@ public abstract class DFSMethods {
1818 private DFSMethods () {
1919 }
2020
21+
2122 /**
22- * Calculates a number of cells around the given slice. Available cells is cells that can be merged
23- * into the slice, so it will remain a rectangle, so only up,down,left,right around an each slice outside cell.
24- * No on the diagonal !
23+ * Step as an entity is an amount of a pizza cells, that can be added to a slice of a pizza or a pizza cell.<br>
24+ * Step as an action is a process of:<br>
25+ * <p>
26+ * * adding cells to a start cell or a start slice<br>
27+ * * validate generated slice according to the pizza slicing instructions<br>
28+ * * if validation passed ->cutting the start cell with added cells from the pizza
2529 *
26- * @param slice given pizza
27- * @param pizza given slice
28- * @return number of cells available to merge into the slice
30+ * @param pizza (mutable) a pizza to perform step on
31+ * @param slice start position for a step
32+ * @return cutted slice from the pizza
2933 */
30- public static int calculateNumberOfFreeCellsAroundSlice (Slice slice , Pizza pizza ) {
31-
32- return 0 ;
33- }
34-
3534 public static Optional <Slice > rightStep (Pizza pizza , Slice slice ) {
3635 List <Cell > slicesRightBorder = slice .cells .stream ()
3736 .filter (cell -> (cell .x == slice .maxX ()) && (cell .y >= slice .minY ()) && (cell .y <= slice .maxY ()))
@@ -45,6 +44,8 @@ public static Optional<Slice> rightStep(Pizza pizza, Slice slice) {
4544 Slice sliceAndStep = new Slice (new ArrayList <>(slice .cells ));
4645 sliceAndStep .cells .addAll (step .cells );
4746 if (!slice .cells .isEmpty () && sliceAndStep .isValid (pizza )) {
47+ //remove the slice and step from the pizza
48+ pizza .getCells ().removeAll (sliceAndStep .cells );
4849 return Optional .of (sliceAndStep );
4950 } else {
5051 return Optional .empty ();
0 commit comments