Skip to content

Instantly share code, notes, and snippets.

@ShirakawaYoshimaru
Created June 10, 2016 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShirakawaYoshimaru/1fe6d52bfa6e8c450ffa5497cd82799d to your computer and use it in GitHub Desktop.
Save ShirakawaYoshimaru/1fe6d52bfa6e8c450ffa5497cd82799d to your computer and use it in GitHub Desktop.
Cubeを10個生成するCubeGeneraterクラスがある。Adapterパターンを使ってCubeを30個生成する機能を作成せよ
public class CubeGenerater
{
public void Make10 ()
{
for (int i = 0; i < 10; i++) {
var position = Vector3.right;
position.x *= i;
Generate (position);
}
}
public void Generate (Vector3 position)
{
var newCube = GameObject.CreatePrimitive (PrimitiveType.Cube);
newCube.transform.position = position;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment