package com.egloos.realmove.dp.strategy; import com.egloos.realmove.dp.strategy.framework.Hand; import com.egloos.realmove.dp.strategy.framework.HandGameStrategy; /** * °¡À§,¹ÙÀ§,º¸ ¼ø¼­´ë·Î ´ÙÀ½ ¼ÕÀ» ³»¹Î´Ù. * ÃÖÃÊÀÇ ¼ÕÀº ·£´ýÇÏ°Ô °áÁ¤ÇÑ´Ù. */ public class SequenceStrategy implements HandGameStrategy { private Hand prevHand = null; public SequenceStrategy() { prevHand = this.getRandom(); } public Hand getRandom() { int i = (int) ( Math.random() * 3 ); if ( i == Hand.SCISSOR.getValue() ) { return Hand.SCISSOR; } else if ( i == Hand.ROCK.getValue() ) { return Hand.ROCK; } else { return Hand.PAPER; } } @Override public Hand next() { Hand next = null; if ( prevHand == Hand.SCISSOR ) { next = Hand.ROCK; } else if ( prevHand == Hand.ROCK ) { next = Hand.PAPER; } else if ( prevHand == Hand.PAPER ) { next = Hand.SCISSOR; } this.prevHand = next; return next; } @Override public void study( int result ) { // do nothing } }