mardi 2 octobre 2018

How to Do a Karel J Robot Question Relating Not Trying to Pick Up Infinite Beepers. Please help tyvm

There is a menace in Karel’s world: an infinite pile of beepers. Yes, it sounds impossible, but occasionally one occurs in the world. If Karel accidentally tries to pick up an infinite pile of beepers, it is forever doomed to pick up beepers from the pile. Karel’s current situation places the robot in grave danger from such a pile. The robot is standing outside of two rooms: one is to the west and one is to the east. Only one of these rooms has a pile of beepers that Karel can pick up. The other room has the dreaded infinite pile of beepers. Karel must decide with room is the safe room, enter it, and pick up all of the beepers. To help Karel decide which room is safe, there is a third pile of beepers on the corner at which Karel is currently standing. If this third pile has an even number of beepers, the safe room is the eastern room. If the pile has an odd number of beepers, the safe room is the western room. There is at least one beeper in the third pile—once Karel has picked up the 3rd pile of beepers and knows how many beepers there is chooses the room—put them back down (do not include them in the beepers you place at the center). When you have picked up all the beepers proceed back to the origin of the world (1, 1), place half of the beepers there with the other half at (1st Street and 2nd Avenue), and then turn off. Create a new class called BeeperPicker. This class will use a subclass called NoLifePicking. The NoLifePicking should have methods that will beeperCheckPick, chooseRoom, goOrigin, and beeperDump. Karel will start at 5th Street and 5th Avenue, facing North and have no beepers.

Aucun commentaire:

Enregistrer un commentaire