私はJavaに書き込んだJavascriptプログラムを変換していますが、Javaで記述する方法がわからないオブジェクトが1つあります。Javaのオブジェクトリテラル
tetros.types = new Array();
tetros.types[0] = new Object();
tetros.types[0].color = "green";
tetros.types[0].rotations = new Array();
tetros.types[0].rotations[0] = new Object();
tetros.types[0].rotations[0].blocks = Array([0,0],[1,0],[2,0],[2,1]);
tetros.types[0].rotations[0].edges ={
"down" :Array([2,0],[2,1]),
"left" :Array([0,0],[1,0],[2,0]),
"right" :Array([2,1],[1,0],[0,0]),
"up" :Array([0,0],[2,1])
}
tetros.types[0].rotations[1] = new Object();
tetros.types[0].rotations[1].blocks = Array([0,0],[0,1],[0,2],[1,0]);
tetros.types[0].rotations[1].edges ={
"down" :Array([0,1],[0,2],[1,0]),
"left" :Array([0,0],[1,0]),
"right" :Array([0,2],[1,0]),
"up" :Array([0,0],[1,0])
}
tetros.types[0].rotations[2] = new Object();
tetros.types[0].rotations[2].blocks = Array([0,0],[0,1],[1,1],[2,1]);
tetros.types[0].rotations[2].edges ={
"down" :Array([0,0],[2,1]),
"left" :Array([0,0],[1,1],[2,1]),
"right" :Array([0,1],[1,1],[2,1]),
"up" :Array([0,0],[0,1])
}
tetros.types[0].rotations[3] = new Object();
tetros.types[0].rotations[3].blocks = Array([0,2],[1,0],[1,1],[1,2]);
tetros.types[0].rotations[3].edges ={
"down" :Array([1,0],[1,1],[1,2]),
"left" :Array([1,0],[0,2]),
"right" :Array([0,2],[1,2]),
"up" :Array([0,2],[1,0],[1,1])
}
tetros.types[1] = new Object();
tetros.types[1].color = "blue";
tetros.types[1].rotations = new Array();
tetros.types[1].rotations[0] = new Object();
tetros.types[1].rotations[0].blocks = Array([0,0],[0,1],[1,0],[1,1]);
tetros.types[1].rotations[0].edges ={
"down" :Array([1,0],[1,1]),
"left" :Array([0,0],[1,0]),
"right" :Array([0,1],[1,1]),
"up" :Array([0,0],[0,1])
}
tetros.types[1].rotations[1] = new Object();
tetros.types[1].rotations[1].blocks = tetros.types[1].rotations[0].blocks;
tetros.types[1].rotations[1].edges = tetros.types[1].rotations[0].edges;
tetros.types[1].rotations[2] = new Object();
tetros.types[1].rotations[2].blocks = tetros.types[1].rotations[0].blocks;
tetros.types[1].rotations[2].edges = tetros.types[1].rotations[0].edges;
tetros.types[1].rotations[3] = new Object();
tetros.types[1].rotations[3].blocks = tetros.types[1].rotations[0].blocks;
tetros.types[1].rotations[3].edges = tetros.types[1].rotations[0].edges;
これはオブジェクト全体の約1/4ですが、残りは同じです。
これはどのようにJavaで記述できますか?
あなたは申し訳ありません。結局のところ、これは人々が困っているときに来る場所です、そうです:-)? –
私は知っていますが、私はすでに今日質問をしました。私はちょうど貪欲にしたくないし、何かを返さずにこのサイトを使い続けている、私は助けるために十分な言語ではありません:/ – Diesal11
それは大丈夫です。あなたができることを学び、あなたができるところを助け、あなたはより良くなるでしょう:) –