[Off-topic] slow_DC4:
Yes. it's me again asking for help about another assignment...

Here is a link to the assignment:

http://www2.hawaii.edu/~ztomasze/teaching/ics211/2012fa/hw/A06b.html

I'm having trouble with the "add" method. The "tiny" variable will not update and keep track of the "tiny Meep".

Here is my code (note: all the println statements are there to let me know what process it is going through.):

public String add (Meep newcomer, boolean print){

Meep tinyMeep;
int move = 0;
int tiny = 0;
int shaft1 = 0;
int shaft2 = 0;

//Drops newcomer into center shaft
burrow.get(1).push(newcomer);

//Moves newcomer over to leftmost shaft if it is empty or it is smaller than current
if (burrow.get(0).size() == 0 || burrow.get(0).peek().compareTo(newcomer) >= 0){
burrow.get(0).push(burrow.get(1).pop());
tiny = 0;
System.out.println("Tiny Meep: "+newcomer.toString());
return "0 "+toString();
}

else {

if (burrow.get(tiny).countLessThan(newcomer) % 2 == 1 || burrow.get(tiny).countLessThan(newcomer) == 1){
//Flurry right
move = 1;
}
else if (burrow.get(tiny).countLessThan(newcomer) % 2 == 0) {
//Flurry left
move = -1;
}

while (burrow.get(1).size() > 0 || burrow.get(2).size() > 0){

Meep tinyMoved = burrow.get(tiny).pop();
tiny = (tiny + move + 3) % 3;
burrow.get(tiny).push(tinyMoved);

//Determines index of other two shafts
switch (tiny){
case 0 : shaft1 = 1;
shaft2 = 2;
break;
case 1 : shaft1 = 0;
shaft2 = 2;
break;
case 2 : shaft1 = 0;
shaft2 = 1;
break;
default: break;
}

System.out.println("teeny: "+tiny);

System.out.println("Shaft1: "+shaft1+" Shaft2: "+shaft2);

if (burrow.get(shaft1).size() > 0 || burrow.get(shaft2).size() > 0){

if (burrow.get(shaft1).size() == 0 && burrow.get(shaft2).peek().compareTo(newcomer) <= 0){
burrow.get(shaft1).push(burrow.get(shaft2).pop());
System.out.println("tiny1. "+tiny);
System.out.println("TM1: "+burrow.get(tiny).peek().toString());
System.out.println("\n1 "+toString());
}
else if (burrow.get(shaft2).size() == 0 && burrow.get(shaft1).peek().compareTo(newcomer) <= 0){
burrow.get(shaft2).push(burrow.get(shaft1).pop());
System.out.println("TM2: "+burrow.get(tiny).peek().toString());
System.out.println("tiny2. "+tiny);
System.out.println("\n2 "+toString());
}
else if (burrow.get(shaft1).size() > 0 || burrow.get(shaft2).size() > 0){
if (tiny == 0){
burrow.get(1).push(burrow.get(tiny).pop());
System.out.println("TM3: "+burrow.get(tiny).peek().toString());
System.out.println("tiny3. "+tiny);
System.out.println("\n3 "+toString());
}
else if (tiny == 1){
burrow.get(2).push(burrow.get(tiny).pop());
System.out.println("TM4: "+burrow.get(tiny).peek().toString());
System.out.println("tiny4. "+tiny);
System.out.println("\n4 "+toString());
}
else {
burrow.get(0).push(burrow.get(tiny).pop());
System.out.println("TM5: "+burrow.get(tiny).peek().toString());
System.out.println("tiny5. "+tiny);
System.out.println("\n5 "+toString());
}
}
}
}
}
return "last return "+toString();
}

Here is one of the sample output (notice where TM (tiny meep) it says M4 rather than M1):

=== ADDING: M1 ===
Tiny Meep: M1
0 { M1
{
{
=== ADDING: M5 ===
teeny: 1
Shaft1: 0 Shaft2: 2
teeny: 2
Shaft1: 0 Shaft2: 1
tiny1. 2
TM1: M1

1 { M5
{
{ M1
teeny: 0
Shaft1: 1 Shaft2: 2
last return { M5, M1
{
{
=== ADDING: M4 ===
teeny: 1
Shaft1: 0 Shaft2: 2
TM4: M4
tiny4. 1

4 { M5
{ M4
{ M1

Thanks in advance.