-
-
Save evanc/8dc8ddaecbca6f63c552 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class smartVic extends Vic { | |
| public void backUpTo(String someSpot) { | |
| while (!someSpot.equals(getPosition())) { | |
| backUp(); | |
| } | |
| } | |
| public boolean hasSomeEmptySlot() { | |
| String point; | |
| point = getPosition(); | |
| while (seesSlot() && seesCD()) { | |
| this.moveOn(); | |
| } | |
| boolean valueToReturn; | |
| valueToReturn = seesSlot(); | |
| while (!point.equals(getPosition())) { | |
| this.backUp(); | |
| } | |
| return valueToReturn; | |
| } | |
| public String lastEmptySlot() { | |
| String place = this.getPosition(); | |
| String lastEmpty = place; // in case no later slot is empty | |
| while (this.seesSlot()) { | |
| if (!this.seesCD()) { | |
| lastEmpty = place; | |
| } | |
| this.moveOn(); | |
| } | |
| this.backUpTo(place); | |
| return lastEmpty; | |
| } | |
| public boolean hasTwoEmpty() { | |
| String point = getPosition(); | |
| boolean valueToReturn; | |
| valueToReturn = false; | |
| if (this.hasSomeEmptySlot()){ | |
| //to next empty slot | |
| while (this.seesCD()) { | |
| this.moveOn(); | |
| } | |
| //to the slot after the first empty slot | |
| this.moveOn(); | |
| while(this.seesSlot() && seesCD()) { | |
| this.moveOn(); | |
| } | |
| valueToReturn = this.seesSlot(); | |
| while(!point.equals(getPosition())) { | |
| this.backUp(); | |
| } | |
| } | |
| return valueToReturn; | |
| } | |
| } |
This file contains hidden or 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
| public class Looper extends smartVic { | |
| public String secondToLastEmpty() { | |
| String spot = this.getPosition(); | |
| String secondToLastEmpty = spot; | |
| if (this.hasTwoEmpty()) { | |
| this.lastEmptySlot(); | |
| this.backUp(); | |
| secondToLastEmpty=spot; | |
| } | |
| return secondToLastEmpty; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment