我想生成一个程序,该程序会生成如下内容(下划线在顶部朝下翻转):output1
注意:我不想使用UNICODE。
但是,相反,我的输出是这样的(下划线显示在底部):output2
public class Landscape {
String terrainString;
Landscape(){
terrainString = "";
}
public void flat(int lengthOfFlatPortion){
for (int count = 0; count < lengthOfFlatPortion; count++) {
terrainString += "_";
}
}
public void hill(int lengthOfHillTop){
terrainString += "/";
for (int count = 0; count < lengthOfHillTop; count++) {
terrainString += "_";
}
terrainString += "\\";
}
public void print(){
System.out.println(terrainString);
}
}
public class Main {
public static void main(String[] args){
Landscape landscape = new Landscape();
//BUILD Landscape Script
landscape.flat(3);
landscape.hill(4);
landscape.flat(6);
landscape.hill(1);
landscape.flat(1);
//END SCRIPT
landscape.print();
}
}
最佳答案
使用‾
char代替_
public void hill(int lengthOfHillTop){
terrainString += "/";
for (int count = 0; count < lengthOfHillTop; count++) {
terrainString += "‾";
}
terrainString += "\\";
}
关于java - 地形图Java,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59815171/