Skip to content

Commit 19b4b20

Browse files
authored
Create Styling.java
1 parent 45a23f3 commit 19b4b20

File tree

1 file changed

+46
-0
lines changed
  • (2) Java Programming: Solving Problems with Software/Week 3/Programs/(1)FoodCSV

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//Program created to color the output and provide with more output readability
2+
//Coder : Phantom-fs
3+
4+
public class Styling
5+
{
6+
static String newline = System.getProperty("line.separator");
7+
8+
public static void line()
9+
{
10+
System.out.print(newline+"--------------------------------------------------");
11+
}
12+
13+
public static void lineTitle ()
14+
{
15+
System.out.print(newline+"=================================================="+newline);
16+
}
17+
18+
public static void line (String text)
19+
{
20+
System.out.print(newline+"--------------------------------------------------"+newline);
21+
System.out.print(text);
22+
System.out.print(newline+"--------------------------------------------------"+newline);
23+
}
24+
25+
public static void lineTitle (String text)
26+
{
27+
System.out.print(newline+"=================================================="+newline);
28+
System.out.print(text);
29+
System.out.print(newline+"=================================================="+newline);
30+
}
31+
32+
public static void color (String text, String color)
33+
{
34+
switch (color)
35+
{
36+
case "red" -> System.out.print(newline+"\u001B[31m" + text + "\u001B[0m");
37+
case "green" -> System.out.print(newline+"\u001B[32m" + text + "\u001B[0m");
38+
case "yellow" -> System.out.print(newline+"\u001B[33m" + text + "\u001B[0m");
39+
case "blue" -> System.out.print(newline+"\u001B[34m" + text + "\u001B[0m");
40+
case "purple" -> System.out.print(newline+"\u001B[35m" + text + "\u001B[0m");
41+
case "cyan" -> System.out.print(newline+"\u001B[36m" + text + "\u001B[0m");
42+
case "white" -> System.out.print(newline+"\u001B[37m" + text + "\u001B[0m");
43+
default -> System.out.print(newline+"\u001B[30m" + text + "\u001B[0m");
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)