This site requires JavaScript, please enable it in your browser!
Greenfoot back
1234567890
1234567890 wrote ...

2020/10/24

ZIG-ZAG MOVEMENT OF CHESS PIECES

1234567890 1234567890

2020/10/24

#
Task 3: Implement the act() method for chess class The goal is to move the chess piece is a zig-zag manner as shown below[Disallowed URL] Implement the act() method of the Chess class to support a zig-zag movement of the chess piece I have no idea how to do it. There's a hint but to me it didn't help: Hints: · Add one instance variable to keep track of the current movement (e.g. private boolean isMovingUp) to the class · Think about the the followings, and use if-statements to check for the conditions, update the instance variable when needed 1. When we should move up? 2. When we should move down? 3. When we should move to the right? 4. When we should stop?
danpost danpost

2020/10/24

#
Answers to hints: 1) every other move; 2) same as (1), but not on same moves; 3) always; 4) when at (right) edge (or after 7 moves, if starting at left edge). If you flip the boolean value every act, it should not be hard to move in a zigzag across the board using an if conditioned on the boolean.
You need to login to post a reply.