Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 099e2dd

Browse files
Create Styling.java
1 parent 2951913 commit 099e2dd

File tree

1 file changed

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

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Coder : Phantom-fs
3+
*/
4+
5+
package ExportsCSV;
6+
7+
import org.jetbrains.annotations.NotNull;
8+
import java.util.*;
9+
10+
public class Styling
11+
{
12+
static String newline = System.getProperty("line.separator");
13+
14+
public static void line()
15+
{
16+
System.out.print(newline+"--------------------------------------------------------------------------------------------------------------------------------------------------------");
17+
}
18+
19+
public static void lineTitle ()
20+
{
21+
System.out.print(newline+"========================================================================================================================================================"+newline);
22+
}
23+
24+
public static void line (String text)
25+
{
26+
System.out.print(newline+"--------------------------------------------------------------------------------------------------------------------------------------------------------"+newline);
27+
System.out.print(text);
28+
System.out.print(newline+"--------------------------------------------------------------------------------------------------------------------------------------------------------"+newline);
29+
}
30+
31+
public static void lineTitle (String text)
32+
{
33+
System.out.print(newline+"======================================================================================================================================================="+newline);
34+
System.out.print(text);
35+
System.out.print(newline+"======================================================================================================================================================="+newline);
36+
}
37+
38+
public static void color (String text, @NotNull String color)
39+
{
40+
switch (color)
41+
{
42+
case "red" -> System.out.print(newline+"\u001B[31m" + text + "\u001B[0m");
43+
case "green" -> System.out.print(newline+"\u001B[32m" + text + "\u001B[0m");
44+
case "yellow" -> System.out.print(newline+"\u001B[33m" + text + "\u001B[0m");
45+
case "blue" -> System.out.print(newline+"\u001B[34m" + text + "\u001B[0m");
46+
case "purple" -> System.out.print(newline+"\u001B[35m" + text + "\u001B[0m");
47+
case "cyan" -> System.out.print(newline+"\u001B[36m" + text + "\u001B[0m");
48+
case "white" -> System.out.print(newline+"\u001B[37m" + text + "\u001B[0m");
49+
default -> System.out.print(newline+"\u001B[30m" + text + "\u001B[0m");
50+
}
51+
}
52+
53+
public static void colorTB (String text, @NotNull String color)
54+
{
55+
Formatter fmt = new Formatter();
56+
switch (color)
57+
{
58+
case "red" ->
59+
{
60+
fmt.format("%-30s", text);
61+
System.out.print("\u001B[31m" + fmt + "\u001B[0m");
62+
}
63+
64+
case "green" ->
65+
{
66+
fmt.format("%-30s", text);
67+
System.out.print("\u001B[32m" + fmt + "\u001B[0m");
68+
}
69+
70+
case "yellow" ->
71+
{
72+
fmt.format("%-30s", text);
73+
System.out.print("\u001B[33m" + fmt + "\u001B[0m");
74+
}
75+
76+
case "blue" ->
77+
{
78+
fmt.format("%-30s", text);
79+
System.out.print("\u001B[34m" + fmt + "\u001B[0m");
80+
}
81+
82+
case "purple" ->
83+
{
84+
fmt.format("%-30s", text);
85+
System.out.print("\u001B[35m" + fmt + "\u001B[0m");
86+
}
87+
88+
case "cyan" ->
89+
{
90+
fmt.format("%-30s", text);
91+
System.out.print("\u001B[36m" + fmt + "\u001B[0m");
92+
}
93+
94+
case "white" ->
95+
{
96+
fmt.format("%-30s", text);
97+
System.out.print("\u001B[37m" + fmt + "\u001B[0m");
98+
}
99+
100+
default ->
101+
{
102+
fmt.format("%-30s", text);
103+
System.out.print("\u001B[30m" + fmt + "\u001B[0m");
104+
}
105+
}
106+
}
107+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /