私が作成しているテキストアドベンチャーで地図を描くのに役立つこのプログラムを作成しました。これまでのところ、あなたが入力した拘束の黒い四角形が描かれています。各行の間に白い線がないようにスペースを取り除く方法はありますか?ここで印刷された行間のスペースを削除するにはどうすればよいですか?
は私のコードです:
import java.util.Scanner;
public class MapGrid {
static String createGrid(int x, int y) {
String output = "";
String block = new String("\u2588\u2588"); //A string of two unicode block symbols: ██
if(x * y != 0) { //If neither x nor y is 0, a map of length x and height y will be returned
for(int n = 1; n <= y; n++) {
for(int i = 1; i <= x; i++) {
output += block;
}
output += "\n";
}
}
return output;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try(Scanner sc = new Scanner(System.in)) {
System.out.println("Please enter the length of your map");
int length = sc.nextInt();
System.out.println("Please enter the height of your map");
int height = sc.nextInt();
System.out.println(createGrid(length,height));
}
}
}
これは時にユーザー入力5,5それが印刷さです:
何私見て大変だったので、私はスクリーンショットを取りましたこのフォントで話し合っていた
新しいブロック行の間には、右に見えないように小さな隙間があります。おそらくこれを修正する方法はありませんが、もしあれば尋ねると思いました。
空白は、文字の上端と行の上端の間のスペースです。あなたの問題は、コードではなくフォントである。 –
ありがとう!しかし、どのようにフォントを変更するのですか? (申し訳ありません、私はとても新しいです) – tarboy9
あなたの出産はどこですか? IDEを使用していますか? –