package com.egloos.realmove.dp.strategy; import com.egloos.realmove.dp.strategy.framework.Hand; import com.egloos.realmove.dp.strategy.framework.HandGameStrategy; /** * ¾î¶² ¼ÕÀÌ À̰åÀ¸¸é, ´ÙÀ½¿¡µµ ¹Ýµå½Ã ±× ¼ÕÀ» ³»¹Î´Ù. * Á³À» °æ¿ì¿£ ·£´ýÇÏ°Ô °áÁ¤ÇÑ´Ù. */ public class WinningStrategy implements HandGameStrategy { private Hand prevHand = null; private boolean won = false; public WinningStrategy() { won = false; } 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() { if ( won == false ) { prevHand = getRandom(); } return prevHand; } @Override public void study( int result ) { if ( result == HandGameStrategy.WIN ) { won = true; } } }