Big Fish Interview Question
iOS DevelopersCountry: United States
Interview Type: In-Person
Something like this ?
GotoFloor(int targetFloor){
String direction = getCurrentDirection();
if (direction.contentEquals("up") && currentFloor > targetFloor) {
// ignore request
return
}
else{
currentFloor++;
if (currentFloor == targetFloor){
OpenDoor(Defaultdelay)
}
}
if (direction.contentEquals("down") && currentFloor < targetFloor) {
// ignore request
return
}
else{
currentFloor--;
if (currentFloor == targetFloor){
OpenDoor(Defaultdelay)
}
}
I think instead of currentFloor++; .......... targetFloor++ should come. Same currentFloor--; .........targetFloor-- should come.
- Abhishek Dangwal February 05, 2015