Skip to content

Instantly share code, notes, and snippets.

@colintsteele
Created May 17, 2017 01:49
Show Gist options
  • Save colintsteele/dd51c3a3323edf88736538e0f959098a to your computer and use it in GitHub Desktop.
Save colintsteele/dd51c3a3323edf88736538e0f959098a to your computer and use it in GitHub Desktop.
Completed assignment
public void draw(int indentation) { //while
boolean shrinks = (topWidth > bottomWidth);
if(shrinks){
for (int lineWidth = topWidth; lineWidth >= bottomWidth; lineWidth-= 2) {
int backgroundCharacterCount = (width - lineWidth)/2;
printLine(lineWidth, backgroundCharacterCount);
}
} else {
for (int lineWidth = topWidth; lineWidth <= bottomWidth; lineWidth+= 2) {
int backgroundCharacterCount = (width - lineWidth)/2;
printLine(lineWidth, backgroundCharacterCount);
}
}
}
public void printLine(int lineWidth, int backgroundCount){
printCharacterRun('-', backgroundCount);
printCharacterRun('*', lineWidth);
printCharacterRun('-', backgroundCount);
printNewLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment