added essential Tag-Modules and Site-Generator

This commit is contained in:
Legit Cheetah 2024-02-05 16:59:26 +01:00
parent c7d531a10c
commit 169c0a4c68
10 changed files with 91 additions and 32 deletions

View File

@ -1,16 +1,10 @@
package main;
import main.htmlTags.*;
import main.htmlSites.siteGeneric;
public class Main {
public static void main(String[] args) {
moduleBody body = new moduleBody();
moduleDiv mainDiv = new moduleDiv();
moduleDiv thirdDiv = new moduleDiv();
moduleDiv secondDiv = new moduleDiv();
body.addModule(mainDiv);
mainDiv.addModule(thirdDiv);
body.addModule(secondDiv);
System.out.println(body.build());
siteGeneric site = new siteGeneric();
System.out.println(site.build());
}
}

View File

@ -0,0 +1,39 @@
package main.htmlSites;
import main.htmlTagModules.moduleBody;
import main.htmlTagModules.moduleGeneric;
import main.htmlTagModules.moduleHead;
import main.htmlTagsEnum;
public class siteGeneric extends moduleGeneric {
moduleHead head;
moduleBody body;
public siteGeneric(){
this(new moduleHead(),new moduleBody());
}
public siteGeneric(moduleHead head){
this(head ,new moduleBody());
}
public siteGeneric(moduleBody body){
this(new moduleHead(),body);
}
siteGeneric(moduleHead head, moduleBody body){
this.head = head;
this.body = body;
setTag(htmlTagsEnum.HTML);
addModule(this.head);
addModule(this.body);
}
@Override
public StringBuilder build() {
StringBuilder buildString = new StringBuilder();
buildString
.append("<!DOCTYPE html>")
.append(super.build());
return buildString;
}
}

View File

@ -0,0 +1,9 @@
package main.htmlTagModules;
import main.htmlTagsEnum;
public class moduleBody extends moduleGeneric{
public moduleBody(){
setTag(htmlTagsEnum.BODY);
}
}

View File

@ -0,0 +1,10 @@
package main.htmlTagModules;
import main.htmlTagsEnum;
public class moduleDiv extends moduleGeneric {
public moduleDiv(){
setTag(htmlTagsEnum.DIV);
}
}

View File

@ -1,14 +1,17 @@
package main.htmlTags;
package main.htmlTagModules;
import main.htmlTagsEnum;
import java.util.ArrayList;
public class moduleGeneric {
String tag = "";
htmlTagsEnum tag = null;
int ID;
ArrayList<moduleGeneric> content = new ArrayList<>();
ArrayList<moduleGeneric> content = new ArrayList<>();
public void addModule(moduleGeneric module){
content.add(module);
}
@ -21,11 +24,11 @@ public class moduleGeneric {
return ID;
}
public void setTag(String tag) {
public void setTag(htmlTagsEnum tag) {
this.tag = tag;
}
public String getTag() {
public htmlTagsEnum getTag() {
return tag;
}
@ -33,14 +36,14 @@ public class moduleGeneric {
StringBuilder buildString = new StringBuilder();
buildString
.append("\n<")
.append(tag)
.append(tag.getTag())
.append(">");
for (main.htmlTags.moduleGeneric moduleGeneric : content) {
for (main.htmlTagModules.moduleGeneric moduleGeneric : content) {
buildString.append(moduleGeneric.build());
}
buildString
.append("\n</")
.append(tag)
.append(tag.getTag())
.append(">");
return buildString;
}

View File

@ -0,0 +1,9 @@
package main.htmlTagModules;
import main.htmlTagsEnum;
public class moduleHTML extends moduleGeneric{
public moduleHTML(){
setTag(htmlTagsEnum.HTML);
}
}

View File

@ -0,0 +1,9 @@
package main.htmlTagModules;
import main.htmlTagsEnum;
public class moduleHead extends moduleGeneric {
public moduleHead(){
setTag(htmlTagsEnum.HEAD);
}
}

View File

@ -1,7 +0,0 @@
package main.htmlTags;
public class moduleBody extends moduleGeneric{
public moduleBody(){
setTag("body");
}
}

View File

@ -1,8 +0,0 @@
package main.htmlTags;
public class moduleDiv extends moduleGeneric {
public moduleDiv(){
setTag("div");
}
}

View File

@ -28,6 +28,7 @@ public enum htmlTagsEnum {
HEADLINE4("h4"),
HEADLINE5("h5"),
HEADLINE6("h6"),
HTML("html"),
INPUT("input"),
INTERNETFRAME("iframe"),
INSERT("insert"),