Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //t = tree char, b = trunk char, s = trunk size
- public static String printTree(char t, char b, int s){
- String out = "";
- int test = s - s + 1;
- for(int i = 0; i <= s/2; i++){ //this part generates the "leaves." I think this part is mostly fine.
- for(int k = 0; k < (Math.ceil(s/2)+1)-(i+1); k++){
- out += " ";
- }
- for(int j = 0; j < test; j++){
- out += t;
- }
- test+=2;
- out += "\n";
- }
- //if the size is even
- if(s%2==0){
- //following line purely for testing various numbers
- System.out.println(s + "\n" + (int)(s*0.25)+"\n"+ Math.ceil((s*0.25)%2) + "\n" + s*0.1);
- if(Math.ceil((s*0.25)%2) == 0){
- for(int i = 0; i < (s*0.25); i++){
- out+= " ";
- }
- for(int i = 0; i <= (s/2); i++){
- out+= b;
- }
- }else{
- for(int i = 0; i < (int)(s*0.25)-((s*0.1)-1); i++){
- out+= " ";
- }
- for(int i = 0; i <= (s/2)+(s*0.1); i++){
- out+= b;
- }
- }
- }else{
- for(int i = 0; i < (test*0.25)-2; i++){
- out+= " ";
- }
- for(int i = 0; i <= test/2; i++){
- out+= b;
- }
- }
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement