Created
November 27, 2014 03:56
-
-
Save anonymous/2deead22fd4a30fbdfdb 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 Looper extends smartVic | |
{ | |
public String secondToLastEmpty() | |
{ | |
String spot=this.getPosition(); | |
String secondToLastEmpty=spot; | |
if (this.hasTwoEmpty()) | |
{this.lastEmptySlot(); | |
this.backUp(); | |
secondToLastEmpty=spot; | |
} | |
return secondToLastEmpty; | |
} //================ | |
} | |
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()) | |
{ | |
while (this.seesCD()) | |
{this.moveOn();} //to next empty slot | |
this.moveOn(); //to the slot after the first empty slot | |
while(this.seesSlot()&&seesCD()) | |
this.moveOn(); | |
valueToReturn=this.seesSlot(); | |
while(!point.equals(getPosition())) | |
{this.backUp();} | |
} | |
return valueToReturn; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment