Skip to content

Instantly share code, notes, and snippets.

@cloneko
Last active August 29, 2015 14:18
Show Gist options
  • Save cloneko/6b80fbf56ae2fa828d6f to your computer and use it in GitHub Desktop.
Save cloneko/6b80fbf56ae2fa828d6f to your computer and use it in GitHub Desktop.
public class kochan{
public static void main(String args[]){
reverseTriangle(10);
System.out.println("--");
square(10);
System.out.println("--");
triangle(10);
}
public static String line(String character,int count){
String str = "";
for(int i = 0;i < count;i++){
str = str + character;
}
return str;
}
public static void square(int lines){
for(int i = 0;i < lines;i++){
System.out.println(line("*",lines));
}
}
public static void reverseTriangle(int lines){
while(lines > 0){
System.out.println(line(".",lines--));
}
}
public static void triangle(int lines){
int current = 1;
while(true){
System.out.println(line(".",current++));
if(current > lines){
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment