aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-21 11:00:08 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-03-21 11:00:08 -0400
commit0d9a193075a5e81133e674a7112ab5eba47a8b65 (patch)
tree965a06efc4e1ab22c8e884686e2786a0391f15ff
downloadxmas-tree-0d9a193075a5e81133e674a7112ab5eba47a8b65.tar.gz
xmas-tree-0d9a193075a5e81133e674a7112ab5eba47a8b65.tar.bz2
xmas-tree-0d9a193075a5e81133e674a7112ab5eba47a8b65.zip
Initial commit
-rw-r--r--.gitignore38
-rw-r--r--.idea/.gitignore8
-rw-r--r--.idea/encodings.xml7
-rw-r--r--.idea/misc.xml17
-rw-r--r--pom.xml17
-rw-r--r--src/main/java/org/example/Main.java75
6 files changed, 162 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store \ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding">
+ <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..3d88e30
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ComposerSettings">
+ <execution />
+ </component>
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
+ <component name="MavenProjectsManager">
+ <option name="originalFiles">
+ <list>
+ <option value="$PROJECT_DIR$/pom.xml" />
+ </list>
+ </option>
+ </component>
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/out" />
+ </component>
+</project> \ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ac0b7e5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.example</groupId>
+ <artifactId>tree</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <maven.compiler.source>22</maven.compiler.source>
+ <maven.compiler.target>22</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+</project> \ No newline at end of file
diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java
new file mode 100644
index 0000000..f5a9fb7
--- /dev/null
+++ b/src/main/java/org/example/Main.java
@@ -0,0 +1,75 @@
+package org.example;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+public class Main {
+
+ static Random RNG = new Random();
+
+ public static final String ANSI_RESET = "\u001B[0m";
+ public static final String ANSI_BLACK = "\u001B[30m";
+ public static final String ANSI_RED = "\u001B[31m";
+ public static final String ANSI_GREEN = "\u001B[32m";
+ public static final String ANSI_YELLOW = "\u001B[33m";
+ public static final String ANSI_BLUE = "\u001B[34m";
+ public static final String ANSI_PURPLE = "\u001B[35m";
+ public static final String ANSI_CYAN = "\u001B[36m";
+ public static final String ANSI_WHITE = "\u001B[37m";
+ public static final String ANSI_ORANGE = "\033[38:5:208m";
+ public static final String ANSI_BROWN = "\033[38:5:52m";
+
+ public static void main(String[] args) {
+ tree(25);
+ }
+
+ public static Map.Entry<Character, String> ornament() {
+ var l = new ArrayList<>(List.of(
+ Map.entry('O', ANSI_RED),
+ Map.entry('^', ANSI_YELLOW),
+ Map.entry('&', ANSI_ORANGE),
+ Map.entry('@', ANSI_BLUE),
+ Map.entry('!', ANSI_WHITE),
+ Map.entry('~', ANSI_PURPLE),
+ Map.entry('$', ANSI_CYAN)
+ ));
+ for (int i = 0; i < 21; i++) {
+ l.add(Map.entry('*', ANSI_GREEN));
+ }
+ return l.get(RNG.nextInt(0, l.size()));
+ }
+
+ public static void tree(int size) {
+ for (int i = 0; i < size; i++) {
+ printSpace(size - i);
+ printOrnament(i * 2 + 1);
+ System.out.println();
+ }
+ for (int i = 0; i < (size/3); i++) {
+ printSpace(size - size/6);
+ printStump(size/3);
+ System.out.println();
+ }
+ }
+
+ public static void printOrnament(int count) {
+ for (int i = 0; i < count; i++) {
+ var o = ornament();
+ System.out.print(o.getValue() + o.getKey() + ANSI_RESET);
+ }
+ }
+
+ public static void printSpace(int count) {
+ for (int i = 0; i < count; i++) {
+ System.out.print(" ");
+ }
+ }
+
+ public static void printStump(int count) {
+ for (int i = 0; i < count; i++) {
+ System.out.print(ANSI_BROWN + '#' + ANSI_RESET);
+ }
+ }
+} \ No newline at end of file