3 leds one button

Sorry. Hope this is clearer.

boolean currentled;
int ledPin =3;
boolean last;

void setup() {
pinMode(2, INPUT); // set the switch pin to be an input
pinMode(3, OUTPUT); // set the yellow LED pin to be an output
pinMode(4, OUTPUT); // set the red LED pin to be an output
pinMode(5, OUTPUT); //set green led as output
}
//function to find out if the 3rd led was the last one pressed
boolean led (boolean last)
{

{
boolean last = ledPin;
if (last !=currentled)
{

currentled= ledPin;

}
return currentled;
}

}

void loop() {
// read the switch input:
//if no button pressed then no leds should be on
if (digitalRead(2)==LOW)
{
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite (5, LOW);
}
//if pressed then turn on the 3rd led
else {
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite (5, LOW);
}

//if the last led that was on was the 3rd then turn on the 5th
while (currentled =led(last)) {
digitalWrite(3, LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
} //else turn on the 4th
digitalWrite(3, LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);

}