Skip to content

Instantly share code, notes, and snippets.

@nabbe
Last active December 25, 2015 00:19
Show Gist options
  • Save nabbe/6886477 to your computer and use it in GitHub Desktop.
Save nabbe/6886477 to your computer and use it in GitHub Desktop.
yumyum
// 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