Skip to content

Commit

Permalink
resolving comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SaurabhKukreja committed Apr 26, 2021
1 parent 34cc565 commit 94776a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ Thanks for all your work!
[CLEMENTJOHNSHAJI](https://github.com/CLEMENTJOHNSHAJI)
[alfr3dosv](https://github.com/alfr3dosv)
[xdvrx1](https://github.com/xdvrx1)
[R1ndT](https://github.com/R1ndT)
[R1ndT](https://github.com/R1ndT)
[SaurabhKukreja](https://github.com/SaurabhKukreja)

License
--------------
Expand Down
1 change: 0 additions & 1 deletion src/com/hotmail/kalebmarc/textfighter/main/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ public class Constants {
public static final String STAR_DIVIDER = "********************************************";
public static final String DASH_DIVIDER = "__________________________________________";
public static final String EMPTY_SPACE_BOX = "";
public static final String BRAND_NAME = "www.TextFighter.tk";

}
54 changes: 27 additions & 27 deletions src/com/hotmail/kalebmarc/textfighter/main/GameUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ public static void showPopup(String header, String subheader, List<String> messa
println(center(Constants.EMPTY_SPACE_BOX));

for (int i = 0; i < inputs.size(); i++) {
int input_num = i+1; // This addition is because our switch case starts from Case 1 and not Case 0
int input_num = i + 1; // This addition is because our switch case starts from Case 1 and not Case 0
String input = input_num + "- " + inputs.get(i);
println(leftAlign(input));
}
println(center(Constants.DASH_DIVIDER));
println(center(Constants.BRAND_NAME));

println(center(Constants.DASH_DIVIDER));
}

Expand All @@ -51,34 +50,35 @@ public static String leftAlign(String s) {
return leftAlign(s, 45, ' ');
}

public static String center(String s, int size, char pad) {
if (s == null || size <= s.length()) {
return s;
}
public static String center(String input, int size, char pad) {
if (input == null || size <= input.length())
return input;

StringBuilder output = new StringBuilder(size);
output.append("|");
output.append(String.valueOf(pad).repeat((size - input.length()) / 2));
output.append(input);

StringBuilder sb = new StringBuilder(size);
sb.append("|");
sb.append(String.valueOf(pad).repeat((size - s.length()) / 2));
sb.append(s);
while (sb.length() < size) {
sb.append(pad);
while (output.length() < size) {
output.append(pad);
}
sb.append("|");
return sb.toString();
output.append("|");
return output.toString();
}

public static String leftAlign(String s, int size, char pad) {
if (s == null || size <= s.length()) {
return s;
}
StringBuilder sb = new StringBuilder(size);
sb.append("|");
sb.append(String.valueOf(pad).repeat(10));
sb.append(s);
while (sb.length() < size) {
sb.append(pad);
public static String leftAlign(String input, int size, char pad) {
if (input == null || size <= input.length())
return input;

StringBuilder output = new StringBuilder(size);
output.append("|");
output.append(String.valueOf(pad).repeat(10));
output.append(input);

while (output.length() < size) {
output.append(pad);
}
sb.append("|");
return sb.toString();
output.append("|");
return output.toString();
}
}

0 comments on commit 94776a3

Please sign in to comment.