Copying and Pasting cs Code
In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.
For example, you can follow the pattern in this listing: private int getInitialBlockNumber(int x, int y, int z) {
if(this.options.board_type == "Solid Cube") {
return -1;
}
if(this.options.board_type == "Hollow Cube") { //hollow cube
if(x == 1 && y == 1 && z == 1) {
return -2;
}
else {
return -1;
}
}
if(this.options.board_type == "Box Outline") { //box outline
if(x == 1 && y == 1) {
return -2;
}
if(x == 1 && z == 1) {
return -2;
}
if(y ==1 && z == 1) {
return -2;
}
else {
return -1;
}
}
if(this.options.board_type == "Four Walls") {
if(x == 1 && z == 1) {
return -2;
}
else {
return -1;
}
}
//default is no corners
if(this.options.board_type == "No Corners/Center") {
if(x==1 && y==1 && z==1) {
return -2;
}
else if(x == 1 || y == 1 || z == 1) {
return -1;
}
else {
return -2;
}
}
//default is no corners
//if(this.options.board_type == "No Corners") {
if(x == 1 || y == 1 || z == 1) {
return -1;
}
else {
return -2;
}
//}
}
if(this.options.board_type == "Solid Cube") {
return -1;
}
if(this.options.board_type == "Hollow Cube") { //hollow cube
if(x == 1 && y == 1 && z == 1) {
return -2;
}
else {
return -1;
}
}
if(this.options.board_type == "Box Outline") { //box outline
if(x == 1 && y == 1) {
return -2;
}
if(x == 1 && z == 1) {
return -2;
}
if(y ==1 && z == 1) {
return -2;
}
else {
return -1;
}
}
if(this.options.board_type == "Four Walls") {
if(x == 1 && z == 1) {
return -2;
}
else {
return -1;
}
}
//default is no corners
if(this.options.board_type == "No Corners/Center") {
if(x==1 && y==1 && z==1) {
return -2;
}
else if(x == 1 || y == 1 || z == 1) {
return -1;
}
else {
return -2;
}
}
//default is no corners
//if(this.options.board_type == "No Corners") {
if(x == 1 || y == 1 || z == 1) {
return -1;
}
else {
return -2;
}
//}
}