Commit 29d67a7f authored by Dr. Martin Goik's avatar Dr. Martin Goik

Adding HTML table source code replacement

parent bf397d35
/target/
/.settings/
.classpath
.project
dependency-reduced-pom.xml
*.log
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
<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>de.hdm_stuttgart.mi.sd1</groupId>
<artifactId>mult_simple_html_table</artifactId>
<version>0.9</version>
<packaging>jar</packaging>
<name>mult_simple_html_table</name>
<url>https://freedocs.mi.hdm-stuttgart.de/sd1_sect_mavenCli.html</url>
<description>HTML multiplication table.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<linksource>true</linksource>
<additionalOptions>
<additionalOption>-html5</additionalOption>
</additionalOptions>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>de.hdm_stuttgart.mi.sd1.App</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
</plugins>
</build>
</project>
package de.hdm_stuttgart.mi.sd1;
/**
* Creating a HTML formatted multiplication table.
*/
public class App {
/**
* @param args Yet unused
*/
public static void main(String[] args) {
final int LIMIT = 20; // The number of records to be printed
System.out.print("""
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>A square table</title>
<style>
table,td,th {
border: 1px solid black;
}
table {
border-collapse: collapse;
}
td {
text-align: right;
}
</style>
</head>
<body>
<table>
<tr>
<th>n</th><th>n * n</th>
</tr>
""");
final int trBlockIndent = 6; // Each <tr>...</tr> is being indented by 6 spaces
for (int i = 0; i <= LIMIT; i++) { // Printing the table's body
System.out.print(("""
<tr>
<td>""" + i + "</td>").indent(trBlockIndent));
System.out.print(("""
<td>""" + i * i + "</td>").indent(trBlockIndent));
System.out.print("""
</tr>
""".indent(trBlockIndent));
}
System.out.print("""
</table>
</body>
</html>""");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="A1" fileName="A1.log" append="false">
<PatternLayout pattern="%t %-5p %c{2} - %m%n"/>
</File>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<!-- You my want to define class or package level per-logger rules -->
<Logger name="de.hdm_stuttgart.mi.sd1.App" level="debug">
<AppenderRef ref="A1"/>
</Logger>
<Root level="info">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment