Text Formatter

File Name: TextFormatter.java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package utils;

public class TextFormatter {
  public static void printRepeatedChar(char ch, int count) {
      System.out.println(String.valueOf(ch).repeat(count));
  }

  public static void printRepeatedString(String str, int count) {
      System.out.println(str.repeat(count));
  }

  public static String getRepeatedChar(char ch, int count) {
      return String.valueOf(ch).repeat(count);
  }

  public static String getRepeatedString(String str, int count) {
      return str.repeat(count);
  }

  // Dash-specific methods for backward compatibility
  public static void printDashes(int count) {
      printRepeatedChar('-', count);
  }

  public static String getDashes(int count) {
      return getRepeatedChar('-', count);
  }

}