- ★★Java質問・相談スレッド174★★ [転載禁止]©2ch.net
967 :デフォルトの名無しさん[]:2015/10/21(水) 10:24:11.78 ID:Nls/btnY - public void process(Node node) {
if (node instanceof A) { int x = node.getX() + id; } else if (node instanceof B) { int y = node.getY() * vel; } } をinstanceofを使わずにする方法としてVisitorパターンがあるですが、 どうやって書けばいいのだろう? interfaceとか色々使うみたいだけど。
|