Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a.
- private boolean hallIsClear() {
- if (pos == hall.length - 1 && facingRight) {
- return true;
- }
- else if (pos == 0 && !facingRight) {
- return true;
- }
- else {
- return false;
- }
- b.
- private void move() {
- if (hall[pos] > 0) {
- hall[pos] -= 1;
- }
- if (hall[pos] == 0) {
- if (!forwarMoveBlocked()) {
- if (facingRight) {
- pos += 1;
- }
- else {
- pos -= 1;
- }
- else {
- if (!facingRight) {
- facingRight == true;
- else {
- !facingRight;
- c.
- public int clearHall() {
- int numMoves = 0;
- while (!hallIsClear()) {
- move();
- numMoves++;
- }
- return numMoves;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement