Last active
December 25, 2015 00:19
-
-
Save nabbe/6886477 to your computer and use it in GitHub Desktop.
yumyum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// package | |
import nabbe.drinks.Juice; | |
/*** | |
* ジュースサーバーっぽい振る舞いをする | |
*/ | |
public class JuiceServer { | |
private Juice juice = null; | |
/** | |
* ジュースを注ぎたす。 | |
* ジュースサーバーが空じゃなかったら、ミックスジュースになっちゃう | |
* | |
* @param juice 継ぎ足そうとしているジュース。 | |
*/ | |
public void charge (Juice juice) { | |
if (this.juice == null) { | |
this.juice = juice; | |
} else { | |
this.juice = new MixJuice(this.juice, juice); | |
} | |
} | |
/** | |
* ジュースサーバーを空にする | |
*/ | |
public void empty () { | |
juice = null; | |
} | |
/** | |
* サーバーのなかのジュースを汲む。 | |
* @return このサーバーのなかのジュース | |
*/ | |
public Juice getJuice () { | |
return juice; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment