Skip to content

Instantly share code, notes, and snippets.

@AnEmortalKid
Created September 9, 2015 21:03
Show Gist options
  • Save AnEmortalKid/009f95ce42af3b6b7104 to your computer and use it in GitHub Desktop.
Save AnEmortalKid/009f95ce42af3b6b7104 to your computer and use it in GitHub Desktop.
/**
* Not completed, hey dude at least give this a try and finish it instead of asking people to do your homework plox
*/
public class EmptyRectangle {
private static String createXAxisWall(int width) {
String firstStar = "*";
String midDashes = "";
for (int i = 0; i < width - 2; i++) {
midDashes += "-";
}
String endStar = "*";
return firstStar + midDashes + endStar;
}
private static String createMidWalls(int width) {
String leftSide = "|";
String midSpaces = "";
for (int i = 0; i < width - 2; i++) {
midSpaces += " ";
}
String rightSide = "|";
return leftSide + midSpaces + rightSide;
}
public static void main(String[] args) {
// for a 4 height 3 rectangle we would do
// top
System.out.println(createXAxisWall(3));
// need 2 rows of mid
for (int i = 0; i < 2; i++)
System.out.println(createMidWalls(3));
// bottom
System.out.println(createXAxisWall(3));
// TODO: You solve the rest
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment