diff --git a/Bwinf_Pakplatz_vscode/.vscode/launch.json b/Bwinf_Pakplatz_vscode/.vscode/launch.json new file mode 100644 index 0000000..3a5284a --- /dev/null +++ b/Bwinf_Pakplatz_vscode/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Launch programm", + "request": "launch", + "mainClass": "programm", + "projectName": "Bwinf_Pakplatz_vscode_7dd615c3" + }, + { + "type": "java", + "name": "Launch Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Launch programm", + "request": "launch", + "mainClass": "programm", + "projectName": "Bwinf_Pakplatz_backup_5ab7755b" + } + ] +} \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/README.TXT b/Bwinf_Pakplatz_vscode/README.TXT new file mode 100644 index 0000000..2bea2dd --- /dev/null +++ b/Bwinf_Pakplatz_vscode/README.TXT @@ -0,0 +1,12 @@ +------------------------------------------------------------------------ +This is the project README file. Here, you should describe your project. +Tell the reader (someone who does not know anything about this project) +all he/she needs to know. The comments should usually include at least: +------------------------------------------------------------------------ + +PROJECT TITLE: +PURPOSE OF PROJECT: +VERSION or DATE: +HOW TO START THIS PROJECT: +AUTHORS: +USER INSTRUCTIONS: diff --git a/Bwinf_Pakplatz_vscode/build-jar/programm.jar b/Bwinf_Pakplatz_vscode/build-jar/programm.jar new file mode 100644 index 0000000..5b54f6e Binary files /dev/null and b/Bwinf_Pakplatz_vscode/build-jar/programm.jar differ diff --git a/Bwinf_Pakplatz_vscode/doc/allclasses.html b/Bwinf_Pakplatz_vscode/doc/allclasses.html new file mode 100644 index 0000000..888f6b0 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/allclasses.html @@ -0,0 +1,20 @@ + + + + + +All Classes + + + + + + +

All Classes

+
+ +
+ + diff --git a/Bwinf_Pakplatz_vscode/doc/constant-values.html b/Bwinf_Pakplatz_vscode/doc/constant-values.html new file mode 100644 index 0000000..09b761b --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/constant-values.html @@ -0,0 +1,35 @@ + + + + + +Constant Field Values + + + + + + + + +
+
+

Constant Field Values

+
+

Contents

+
+
+
+ + diff --git a/Bwinf_Pakplatz_vscode/doc/element-list b/Bwinf_Pakplatz_vscode/doc/element-list new file mode 100644 index 0000000..147af06 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/element-list @@ -0,0 +1 @@ +unnamed package diff --git a/Bwinf_Pakplatz_vscode/doc/index.html b/Bwinf_Pakplatz_vscode/doc/index.html new file mode 100644 index 0000000..26d0d4e --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/index.html @@ -0,0 +1,23 @@ + + + + + +Generated Documentation (Untitled) + + + + + + + +
+ +

programm.html

+
+ + diff --git a/Bwinf_Pakplatz_vscode/doc/logfile.txt b/Bwinf_Pakplatz_vscode/doc/logfile.txt new file mode 100644 index 0000000..b8cb862 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/logfile.txt @@ -0,0 +1,36 @@ +Class documentation +<---- javadoc command: ----> +C:\Program Files\BlueJ\jdk\bin\javadoc.exe +-author +-version +-nodeprecated +-package +-Xdoclint:none +-noindex +-notree +-nohelp +-nonavbar +-source +11 +-classpath +C:\Program Files\BlueJ\lib\bluejcore.jar;C:\Program Files\BlueJ\lib\junit-4.12.jar;C:\Program Files\BlueJ\lib\junit-jupiter-5.5.2.jar;C:\Program Files\BlueJ\lib\junit-jupiter-api-5.5.2.jar;C:\Program Files\BlueJ\lib\junit-jupiter-engine-5.5.2.jar;C:\Program Files\BlueJ\lib\junit-jupiter-migrationsupport-5.5.2.jar;C:\Program Files\BlueJ\lib\junit-jupiter-params-5.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-commons-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-console-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-console-standalone-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-engine-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-launcher-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-reporting-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-runner-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-suite-api-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-platform-testkit-1.5.2.jar;C:\Program Files\BlueJ\lib\junit-quickcheck-core-0.9.jar;C:\Program Files\BlueJ\lib\junit-vintage-engine-5.5.2.jar;C:\Program Files\BlueJ\lib\hamcrest-core-1.3.jar;C:\Program Files\BlueJ\lib\hamcrest-library-1.3.jar;C:\Program Files\BlueJ\lib\lang-stride.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.base.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.controls.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.fxml.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.graphics.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.media.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.properties.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.swing.jar;C:\Program Files\BlueJ\lib\javafx\lib\javafx.web.jar;C:\Users\Jordi\BWINF_Parkplatz +-d +C:\Users\Jordi\BWINF_Parkplatz\doc +-encoding +UTF-8 +-charset +UTF-8 +C:\Users\Jordi\BWINF_Parkplatz\programm.java +<---- end of javadoc command ----> +Loading source file C:\Users\Jordi\BWINF_Parkplatz\programm.java... +Constructing Javadoc information... +Standard Doclet version 11.0.10 +Building tree for all the packages and classes... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\programm.html... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\package-summary.html... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\constant-values.html... +Building index for all the packages and classes... +Building index for all classes... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\allclasses.html... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\allclasses.html... +Generating C:\Users\Jordi\BWINF_Parkplatz\doc\index.html... diff --git a/Bwinf_Pakplatz_vscode/doc/package-summary.html b/Bwinf_Pakplatz_vscode/doc/package-summary.html new file mode 100644 index 0000000..71d18cb --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/package-summary.html @@ -0,0 +1,51 @@ + + + + + +<Unnamed> + + + + + + + + +
+
+

Package <Unnamed>

+
+
+ +
+
+ + diff --git a/Bwinf_Pakplatz_vscode/doc/programm.html b/Bwinf_Pakplatz_vscode/doc/programm.html new file mode 100644 index 0000000..6269400 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/programm.html @@ -0,0 +1,467 @@ + + + + + +programm + + + + + + + + + +
+
+

Class programm

+
+
+ +
+
    +
  • +
    +
    public class programm
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      char[]arr 
      (package private) java.lang.Stringfilename 
      (package private) java.lang.Stringfirst 
      (package private) inthCars 
      (package private) java.lang.Stringlast 
      (package private) java.util.Scannerscan 
      char[]tmpArr 
      (package private) intvCars 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      programm() 
      programm​(java.lang.String pFilename) 
      +
    • +
    +
    + +
    + +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        scan

        +
        java.util.Scanner scan
        +
      • +
      + + + +
        +
      • +

        first

        +
        java.lang.String first
        +
      • +
      + + + +
        +
      • +

        last

        +
        java.lang.String last
        +
      • +
      + + + +
        +
      • +

        filename

        +
        java.lang.String filename
        +
      • +
      + + + +
        +
      • +

        hCars

        +
        int hCars
        +
      • +
      + + + +
        +
      • +

        vCars

        +
        int vCars
        +
      • +
      + + + +
        +
      • +

        arr

        +
        public char[] arr
        +
      • +
      + + + +
        +
      • +

        tmpArr

        +
        public char[] tmpArr
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        programm

        +
        public programm()
        +
      • +
      + + + +
        +
      • +

        programm

        +
        public programm​(java.lang.String pFilename)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        readFile

        +
        public void readFile()
        +
      • +
      + + + +
        +
      • +

        rereadFile

        +
        public void rereadFile()
        +
      • +
      + + + +
        +
      • +

        read

        +
        public void read()
        +
      • +
      + + + +
        +
      • +

        createArray

        +
        public void createArray()
        +
      • +
      + + + +
        +
      • +

        outputVars

        +
        public void outputVars()
        +
      • +
      + + + +
        +
      • +

        test

        +
        public void test()
        +
      • +
      + + + +
        +
      • +

        hCars

        +
        public int hCars()
        +
      • +
      + + + +
        +
      • +

        vCars

        +
        public int vCars()
        +
      • +
      + + + +
        +
      • +

        solve

        +
        public void solve()
        +
      • +
      + + + +
        +
      • +

        setArr

        +
        public void setArr()
        +
      • +
      + + + +
        +
      • +

        canLeft

        +
        public boolean canLeft​(int ppos)
        +
      • +
      + + + +
        +
      • +

        canRight

        +
        public boolean canRight​(int ppos)
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ + + diff --git a/Bwinf_Pakplatz_vscode/doc/script.js b/Bwinf_Pakplatz_vscode/doc/script.js new file mode 100644 index 0000000..7dc93c4 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/script.js @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +var moduleSearchIndex; +var packageSearchIndex; +var typeSearchIndex; +var memberSearchIndex; +var tagSearchIndex; +function loadScripts(doc, tag) { + createElem(doc, tag, 'jquery/jszip/dist/jszip.js'); + createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils.js'); + if (window.navigator.userAgent.indexOf('MSIE ') > 0 || window.navigator.userAgent.indexOf('Trident/') > 0 || + window.navigator.userAgent.indexOf('Edge/') > 0) { + createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils-ie.js'); + } + createElem(doc, tag, 'search.js'); + + $.get(pathtoroot + "module-search-index.zip") + .done(function() { + JSZipUtils.getBinaryContent(pathtoroot + "module-search-index.zip", function(e, data) { + JSZip.loadAsync(data).then(function(zip){ + zip.file("module-search-index.json").async("text").then(function(content){ + moduleSearchIndex = JSON.parse(content); + }); + }); + }); + }); + $.get(pathtoroot + "package-search-index.zip") + .done(function() { + JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) { + JSZip.loadAsync(data).then(function(zip){ + zip.file("package-search-index.json").async("text").then(function(content){ + packageSearchIndex = JSON.parse(content); + }); + }); + }); + }); + $.get(pathtoroot + "type-search-index.zip") + .done(function() { + JSZipUtils.getBinaryContent(pathtoroot + "type-search-index.zip", function(e, data) { + JSZip.loadAsync(data).then(function(zip){ + zip.file("type-search-index.json").async("text").then(function(content){ + typeSearchIndex = JSON.parse(content); + }); + }); + }); + }); + $.get(pathtoroot + "member-search-index.zip") + .done(function() { + JSZipUtils.getBinaryContent(pathtoroot + "member-search-index.zip", function(e, data) { + JSZip.loadAsync(data).then(function(zip){ + zip.file("member-search-index.json").async("text").then(function(content){ + memberSearchIndex = JSON.parse(content); + }); + }); + }); + }); + $.get(pathtoroot + "tag-search-index.zip") + .done(function() { + JSZipUtils.getBinaryContent(pathtoroot + "tag-search-index.zip", function(e, data) { + JSZip.loadAsync(data).then(function(zip){ + zip.file("tag-search-index.json").async("text").then(function(content){ + tagSearchIndex = JSON.parse(content); + }); + }); + }); + }); + if (!moduleSearchIndex) { + createElem(doc, tag, 'module-search-index.js'); + } + if (!packageSearchIndex) { + createElem(doc, tag, 'package-search-index.js'); + } + if (!typeSearchIndex) { + createElem(doc, tag, 'type-search-index.js'); + } + if (!memberSearchIndex) { + createElem(doc, tag, 'member-search-index.js'); + } + if (!tagSearchIndex) { + createElem(doc, tag, 'tag-search-index.js'); + } + $(window).resize(function() { + $('.navPadding').css('padding-top', $('.fixedNav').css("height")); + }); +} + +function createElem(doc, tag, path) { + var script = doc.createElement(tag); + var scriptElement = doc.getElementsByTagName(tag)[0]; + script.src = pathtoroot + path; + scriptElement.parentNode.insertBefore(script, scriptElement); +} + +function show(type) { + count = 0; + for (var key in data) { + var row = document.getElementById(key); + if ((data[key] & type) !== 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) { + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} + +function updateModuleFrame(pFrame, cFrame) { + top.packageFrame.location = pFrame; + top.classFrame.location = cFrame; +} diff --git a/Bwinf_Pakplatz_vscode/doc/stylesheet.css b/Bwinf_Pakplatz_vscode/doc/stylesheet.css new file mode 100644 index 0000000..fa24676 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/doc/stylesheet.css @@ -0,0 +1,906 @@ +/* + * Javadoc style sheet + */ + +@import url('resources/fonts/dejavu.css'); + +/* + * Styles for individual HTML elements. + * + * These are styles that are specific to individual HTML elements. Changing them affects the style of a particular + * HTML element throughout the page. + */ + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; + padding:0; + height:100%; + width:100%; +} +iframe { + margin:0; + padding:0; + height:100%; + width:100%; + overflow-y:scroll; + border:none; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a[href]:hover, a[href]:focus { + text-decoration:none; + color:#bb7a2a; +} +a[name] { + color:#353833; +} +a[name]:before, a[name]:target, a[id]:before, a[id]:target { + content:""; + display:inline-block; + position:relative; + padding-top:129px; + margin-top:-129px; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} + +/* + * Styles for HTML generated by javadoc. + * + * These are style classes that are used by the standard doclet to generate HTML documentation. + */ + +/* + * Styles for document title and copyright. + */ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* + * Styles for navigation bar. + */ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.navPadding { + padding-top: 107px; +} +.fixedNav { + position:fixed; + width:100%; + z-index:999; + background-color:#ffffff; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.navListSearch { + float:right; + margin:0 0 0 0; + padding:0; +} +ul.navListSearch li { + list-style:none; + float:right; + padding: 5px 6px; + text-transform:uppercase; +} +ul.navListSearch li label { + position:relative; + right:-16px; +} +ul.subNavList li { + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* + * Styles for page header and footer. + */ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexNav { + position:relative; + font-size:12px; + background-color:#dee3e9; +} +.indexNav ul { + margin-top:0; + padding:5px; +} +.indexNav ul li { + display:inline; + list-style-type:none; + padding-right:10px; + text-transform:uppercase; +} +.indexNav h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* + * Styles for headings. + */ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* + * Styles for page layout containers. + */ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer, +.allClassesContainer, .allPackagesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* + * Styles for lists. + */ +li.circle { + list-style:circle; +} +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* + * Styles for tables. + */ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary, +.requiresSummary, .packagesSummary, .providesSummary, .usesSummary { + width:100%; + border-spacing:0; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary, .requiresSummary, .packagesSummary, .providesSummary, .usesSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption, +.requiresSummary caption, .packagesSummary caption, .providesSummary caption, .usesSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.constantsSummary caption a:link, .deprecatedSummary caption a:link, +.requiresSummary caption a:link, .packagesSummary caption a:link, .providesSummary caption a:link, +.usesSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.requiresSummary caption a:hover, .packagesSummary caption a:hover, .providesSummary caption a:hover, +.usesSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.constantsSummary caption a:active, .deprecatedSummary caption a:active, +.requiresSummary caption a:active, .packagesSummary caption a:active, .providesSummary caption a:active, +.usesSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.constantsSummary caption a:visited, .deprecatedSummary caption a:visited, +.requiresSummary caption a:visited, .packagesSummary caption a:visited, .providesSummary caption a:visited, +.usesSummary caption a:visited { + color:#FFFFFF; +} +.useSummary caption a:link, .useSummary caption a:hover, .useSummary caption a:active, +.useSummary caption a:visited { + color:#1f389c; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span, +.requiresSummary caption span, .packagesSummary caption span, .providesSummary caption span, +.usesSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span, .packagesSummary caption span.activeTableTab span, +.overviewSummary caption span.activeTableTab span, .typeSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span, .packagesSummary caption span.tableTab span, +.overviewSummary caption span.tableTab span, .typeSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab, +.packagesSummary caption span.tableTab, .packagesSummary caption span.activeTableTab, +.overviewSummary caption span.tableTab, .overviewSummary caption span.activeTableTab, +.typeSummary caption span.tableTab, .typeSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd, +.requiresSummary .tabEnd, .packagesSummary .tabEnd, .providesSummary .tabEnd, .usesSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd, .packagesSummary .activeTableTab .tabEnd, +.overviewSummary .activeTableTab .tabEnd, .typeSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd, .packagesSummary .tableTab .tabEnd, +.overviewSummary .tableTab .tabEnd, .typeSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; +} +.rowColor th, .altColor th { + font-weight:normal; +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td, +.requiresSummary td, .packagesSummary td, .providesSummary td, .usesSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colFirst, th.colSecond, th.colLast, th.colConstructorName, th.colDeprecatedItemName, .useSummary th, +.constantsSummary th, .packagesSummary th, td.colFirst, td.colSecond, td.colLast, .useSummary td, +.constantsSummary td { + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colSecond, th.colLast, th.colConstructorName, th.colDeprecatedItemName, .constantsSummary th, +.packagesSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + font-size:13px; +} +td.colSecond, th.colSecond, td.colLast, th.colConstructorName, th.colDeprecatedItemName, th.colLast { + font-size:13px; +} +.constantsSummary th, .packagesSummary th { + font-size:13px; +} +.providesSummary th.colFirst, .providesSummary th.colLast, .providesSummary td.colFirst, +.providesSummary td.colLast { + white-space:normal; + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.requiresSummary td.colFirst, .requiresSummary th.colFirst, +.packagesSummary td.colFirst, .packagesSummary td.colSecond, .packagesSummary th.colFirst, .packagesSummary th, +.usesSummary td.colFirst, .usesSummary th.colFirst, +.providesSummary td.colFirst, .providesSummary th.colFirst, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName, +.typeSummary td.colFirst, .typeSummary th.colFirst { + vertical-align:top; +} +.packagesSummary th.colLast, .packagesSummary td.colLast { + white-space:normal; +} +td.colFirst a:link, td.colFirst a:visited, +td.colSecond a:link, td.colSecond a:visited, +th.colFirst a:link, th.colFirst a:visited, +th.colSecond a:link, th.colSecond a:visited, +th.colConstructorName a:link, th.colConstructorName a:visited, +th.colDeprecatedItemName a:link, th.colDeprecatedItemName a:visited, +.constantValuesContainer td a:link, .constantValuesContainer td a:visited, +.allClassesContainer td a:link, .allClassesContainer td a:visited, +.allPackagesContainer td a:link, .allPackagesContainer td a:visited { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor, .altColor th { + background-color:#FFFFFF; +} +.rowColor, .rowColor th { + background-color:#EEEEEF; +} +/* + * Styles for contents. + */ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} +td.colLast div { + padding-top:0px; +} +td.colLast a { + padding-bottom:3px; +} +/* + * Styles for formatting effect. + */ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .implementationLabel, .memberNameLabel, .memberNameLink, +.moduleLabelInPackage, .moduleLabelInType, .overrideSpecifyLabel, .packageLabelInType, +.packageHierarchyLabel, .paramLabel, .returnLabel, .seeLabel, .simpleTagLabel, +.throwsLabel, .typeNameLabel, .typeNameLink, .searchTagLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} +.deprecationBlock { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; + border-style:solid; + border-width:thin; + border-radius:10px; + padding:10px; + margin-bottom:10px; + margin-right:10px; + display:inline-block; +} +div.block div.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} +div.contentContainer ul.blockList li.blockList h2 { + padding-bottom:0px; +} +/* + * Styles for IFRAME. + */ +.mainContainer { + margin:0 auto; + padding:0; + height:100%; + width:100%; + position:fixed; + top:0; + left:0; +} +.leftContainer { + height:100%; + position:fixed; + width:320px; +} +.leftTop { + position:relative; + float:left; + width:315px; + top:0; + left:0; + height:30%; + border-right:6px solid #ccc; + border-bottom:6px solid #ccc; +} +.leftBottom { + position:relative; + float:left; + width:315px; + bottom:0; + left:0; + height:70%; + border-right:6px solid #ccc; + border-top:1px solid #000; +} +.rightContainer { + position:absolute; + left:320px; + top:0; + bottom:0; + height:100%; + right:0; + border-left:1px solid #000; +} +.rightIframe { + margin:0; + padding:0; + height:100%; + right:30px; + width:100%; + overflow:visible; + margin-bottom:30px; +} +/* + * Styles specific to HTML5 elements. + */ +main, nav, header, footer, section { + display:block; +} +/* + * Styles for javadoc search. + */ +.ui-autocomplete-category { + font-weight:bold; + font-size:15px; + padding:7px 0 7px 3px; + background-color:#4D7A97; + color:#FFFFFF; +} +.resultItem { + font-size:13px; +} +.ui-autocomplete { + max-height:85%; + max-width:65%; + overflow-y:scroll; + overflow-x:scroll; + white-space:nowrap; + box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); +} +ul.ui-autocomplete { + position:fixed; + z-index:999999; +} +ul.ui-autocomplete li { + float:left; + clear:both; + width:100%; +} +.resultHighlight { + font-weight:bold; +} +#search { + background-image:url('resources/glass.png'); + background-size:13px; + background-repeat:no-repeat; + background-position:2px 3px; + padding-left:20px; + position:relative; + right:-18px; +} +#reset { + background-color: rgb(255,255,255); + background-image:url('resources/x.png'); + background-position:center; + background-repeat:no-repeat; + background-size:12px; + border:0 none; + width:16px; + height:17px; + position:relative; + left:-4px; + top:-4px; + font-size:0px; +} +.watermark { + color:#545454; +} +.searchTagDescResult { + font-style:italic; + font-size:11px; +} +.searchTagHolderResult { + font-style:italic; + font-size:12px; +} +.searchTagResult:before, .searchTagResult:target { + color:red; +} +.moduleGraph span { + display:none; + position:absolute; +} +.moduleGraph:hover span { + display:block; + margin: -100px 0 0 100px; + z-index: 1; +} +.methodSignature { + white-space:normal; +} + +/* + * Styles for user-provided tables. + * + * borderless: + * No borders, vertical margins, styled caption. + * This style is provided for use with existing doc comments. + * In general, borderless tables should not be used for layout purposes. + * + * plain: + * Plain borders around table and cells, vertical margins, styled caption. + * Best for small tables or for complex tables for tables with cells that span + * rows and columns, when the "striped" style does not work well. + * + * striped: + * Borders around the table and vertical borders between cells, striped rows, + * vertical margins, styled caption. + * Best for tables that have a header row, and a body containing a series of simple rows. + */ + +table.borderless, +table.plain, +table.striped { + margin-top: 10px; + margin-bottom: 10px; +} +table.borderless > caption, +table.plain > caption, +table.striped > caption { + font-weight: bold; + font-size: smaller; +} +table.borderless th, table.borderless td, +table.plain th, table.plain td, +table.striped th, table.striped td { + padding: 2px 5px; +} +table.borderless, +table.borderless > thead > tr > th, table.borderless > tbody > tr > th, table.borderless > tr > th, +table.borderless > thead > tr > td, table.borderless > tbody > tr > td, table.borderless > tr > td { + border: none; +} +table.borderless > thead > tr, table.borderless > tbody > tr, table.borderless > tr { + background-color: transparent; +} +table.plain { + border-collapse: collapse; + border: 1px solid black; +} +table.plain > thead > tr, table.plain > tbody tr, table.plain > tr { + background-color: transparent; +} +table.plain > thead > tr > th, table.plain > tbody > tr > th, table.plain > tr > th, +table.plain > thead > tr > td, table.plain > tbody > tr > td, table.plain > tr > td { + border: 1px solid black; +} +table.striped { + border-collapse: collapse; + border: 1px solid black; +} +table.striped > thead { + background-color: #E3E3E3; +} +table.striped > thead > tr > th, table.striped > thead > tr > td { + border: 1px solid black; +} +table.striped > tbody > tr:nth-child(even) { + background-color: #EEE +} +table.striped > tbody > tr:nth-child(odd) { + background-color: #FFF +} +table.striped > tbody > tr > th, table.striped > tbody > tr > td { + border-left: 1px solid black; + border-right: 1px solid black; +} +table.striped > tbody > tr > th { + font-weight: normal; +} diff --git a/Bwinf_Pakplatz_vscode/parkplatz0.txt b/Bwinf_Pakplatz_vscode/parkplatz0.txt new file mode 100644 index 0000000..9673085 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz0.txt @@ -0,0 +1,4 @@ +A G +2 +H 2 +I 5 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/parkplatz1.txt b/Bwinf_Pakplatz_vscode/parkplatz1.txt new file mode 100644 index 0000000..bb96ed9 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz1.txt @@ -0,0 +1,6 @@ +A N +4 +O 1 +P 3 +Q 6 +R 10 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/parkplatz2.txt b/Bwinf_Pakplatz_vscode/parkplatz2.txt new file mode 100644 index 0000000..6ffddb6 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz2.txt @@ -0,0 +1,7 @@ +A N +5 +O 2 +P 5 +Q 7 +R 9 +S 12 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/parkplatz3.txt b/Bwinf_Pakplatz_vscode/parkplatz3.txt new file mode 100644 index 0000000..9441cbc --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz3.txt @@ -0,0 +1,7 @@ +A N +5 +O 1 +P 4 +Q 8 +R 10 +S 12 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/parkplatz4.txt b/Bwinf_Pakplatz_vscode/parkplatz4.txt new file mode 100644 index 0000000..1ec9f0a --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz4.txt @@ -0,0 +1,7 @@ +A P +5 +Q 0 +R 2 +S 6 +T 10 +U 13 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/parkplatz5.txt b/Bwinf_Pakplatz_vscode/parkplatz5.txt new file mode 100644 index 0000000..b8dea60 --- /dev/null +++ b/Bwinf_Pakplatz_vscode/parkplatz5.txt @@ -0,0 +1,8 @@ +A T +5 +U 0 +V 2 +W 4 +X 6 +Y 8 +Z 10 \ No newline at end of file diff --git a/Bwinf_Pakplatz_vscode/programm.class b/Bwinf_Pakplatz_vscode/programm.class new file mode 100644 index 0000000..8750bb6 Binary files /dev/null and b/Bwinf_Pakplatz_vscode/programm.class differ diff --git a/Bwinf_Pakplatz_vscode/programm.ctxt b/Bwinf_Pakplatz_vscode/programm.ctxt new file mode 100644 index 0000000..58252bc --- /dev/null +++ b/Bwinf_Pakplatz_vscode/programm.ctxt @@ -0,0 +1,35 @@ +#BlueJ class context +comment0.target=programm +comment1.params= +comment1.target=programm() +comment10.params= +comment10.target=void\ setArr2() +comment11.params=ppos +comment11.target=boolean\ canLeft(int) +comment12.params=ppos +comment12.target=boolean\ canRight(int) +comment13.params=input +comment13.target=boolean\ canCanRight(int) +comment14.params=input +comment14.target=boolean\ canCanLeft(int) +comment15.params=car +comment15.target=void\ moveRight(char) +comment16.params=car +comment16.target=void\ moveLeft(char) +comment2.params=pFilename +comment2.target=programm(java.lang.String) +comment3.params= +comment3.target=void\ readFile() +comment4.params= +comment4.target=void\ read() +comment5.params= +comment5.target=void\ createArray() +comment6.params= +comment6.target=int\ vCars() +comment7.params= +comment7.target=void\ printArr() +comment8.params= +comment8.target=void\ solve() +comment9.params=input +comment9.target=boolean\ goRight(int) +numComments=17 diff --git a/Bwinf_Pakplatz_vscode/programm.jar b/Bwinf_Pakplatz_vscode/programm.jar new file mode 100644 index 0000000..648d081 Binary files /dev/null and b/Bwinf_Pakplatz_vscode/programm.jar differ diff --git a/Bwinf_Pakplatz_vscode/programm.java b/Bwinf_Pakplatz_vscode/programm.java new file mode 100644 index 0000000..a075daf --- /dev/null +++ b/Bwinf_Pakplatz_vscode/programm.java @@ -0,0 +1,278 @@ +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; + +public class programm +{ + Scanner scan; + Scanner scanOut; + Scanner scanOut2; + String last; + String filename; + int vCars; + int hCars; + char[] arr; + char[] tmpArr; + String tmpOutput; + int steps; + char tmpChar2; + public static void main(String[] args) + { + + if(args.length == 0) + { + new programm(); + } + else{ + for (int i=0;i=2 ) + { + cl = true; + } + return cl; + } + public boolean canRight(int ppos) + { + boolean cr = false; + if ( pposinput && tmpArr[i] == '0') + { + n++; + } + } + if (n>0 && goRight(input) == true) + { + ccr = true; + } + if (n>=2 && goRight(input) == false) + { + ccr = true; + } + return ccr; + } + public boolean canCanLeft(int input) + { + boolean ccl = false; + int n = 0; + for(int i=0;i0 && goRight(input) == false) + { + ccl = true; + } + if (n>=2 && goRight(input) == true) + { + ccl = true; + } + return ccl; + } + + public void moveRight(char car) + { + boolean found = false ; + int t = 0; + while (found == false) + { + if(tmpArr[t] == car) + { + if(tmpArr[t+2] != '0' && canRight(t+2) == true ) + { + moveRight(tmpArr[t+2]); + } + if (canRight(t) == false) + { + moveLeft(car); + } + tmpOutput += tmpArr[t]; + tmpOutput += " Rechts "; + tmpArr[t+2]=tmpArr[t]; + tmpArr[t]='0'; + found = true; + } + t++; + } + } + public void moveLeft(char car) + { + boolean found = false ; + int t = 0; + while (found == false) + { + if(tmpArr[t] == car) + { + if(tmpArr[t-1] != '0' && canLeft(t+1)) + { + moveLeft(tmpArr[t-1]); + } + tmpOutput += tmpArr[t]; + tmpOutput += " Links "; + tmpArr[t-1]=tmpArr[t]; + tmpArr[t+1]='0'; + found = true; + } + t++; + } + } + + + +} + diff --git a/Dijkstra_vs/backup/input.txt b/Dijkstra_vs/backup/input.txt new file mode 100644 index 0000000..98978a4 --- /dev/null +++ b/Dijkstra_vs/backup/input.txt @@ -0,0 +1,15 @@ +n 100 250 +n 266 100 +n 266 400 +n 433 100 +n 433 300 +n 600 250 +e 2 4 33 +e 3 5 2 +e 3 4 20 +e 4 5 1 +e 2 3 20 +e 1 4 10 +e 1 3 50 +e 0 2 20 +e 0 1 10 diff --git a/Dijkstra_vs/backup/input2.txt b/Dijkstra_vs/backup/input2.txt new file mode 100644 index 0000000..4062929 --- /dev/null +++ b/Dijkstra_vs/backup/input2.txt @@ -0,0 +1,14 @@ +n 100 250 +n 200 250 +n 350 100 +n 350 400 +n 500 250 +n 600 250 +e 0 1 10 +e 1 2 1 +e 2 4 3 +e 4 3 10 +e 3 1 4 +e 4 5 22 + + diff --git a/Dijkstra_vs/backup/input3.txt b/Dijkstra_vs/backup/input3.txt new file mode 100644 index 0000000..35d9d6b --- /dev/null +++ b/Dijkstra_vs/backup/input3.txt @@ -0,0 +1,39 @@ +n 217 300 +n 403 316 +n 118 60 +n 645 303 +n 402 71 +n 245 234 +n 580 376 +n 448 483 +n 146 366 +n 453 215 +e 0 5 343 +e 1 6 954 +e 1 5 879 +e 2 5 1054 +e 2 4 1364 +e 3 6 433 +e 4 5 1106 +e 8 0 464 +e 0 7 1435 +e 1 7 811 +e 6 7 837 +e 4 9 766 +e 3 9 1053 +e 1 9 524 +e 5 0 343 +e 6 1 954 +e 5 1 879 +e 5 2 1054 +e 4 2 1364 +e 6 3 433 +e 5 4 1106 +e 0 8 464 +e 7 0 1435 +e 7 1 811 +e 7 6 837 +e 9 4 766 +e 9 3 1053 +e 9 1 524 + diff --git a/Dijkstra_vs/backup/yeet.class b/Dijkstra_vs/backup/yeet.class new file mode 100644 index 0000000..664c235 Binary files /dev/null and b/Dijkstra_vs/backup/yeet.class differ diff --git a/Dijkstra_vs/backup/yeet.java b/Dijkstra_vs/backup/yeet.java new file mode 100644 index 0000000..e2b1e22 --- /dev/null +++ b/Dijkstra_vs/backup/yeet.java @@ -0,0 +1,132 @@ +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; +import javax.swing.*; +import java.awt.*; +import java.lang.Math; +import java.util.Random; +import java.util.*; + +public class yeet extends JFrame { + Scanner scan; + int n, e;// n: Anzahl Punkte, e: Anzahl Wege + String tmpStr1, filename; + int[] xarr, yarr; + int[][] earr; + char tmpChar; + + public static void main(String[] args) { + if (args.length == 0) { + new yeet(); + } else { + for (int i = 0; i < args.length; i++) { + new yeet(args[i]); + } + } + } + + public yeet() { + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + filename = "input.txt"; + steps(); + } + + public yeet(String input) { + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + filename = input; + steps(); + } + + public void steps() { + readFile(); // einlesen + readNE(); // anzahl von n und e finden. Als int n und e gespeichert + make(); // Arrays erstellen + repaint(); + } + + public void readFile() { + try { + scan = new Scanner(new File(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + } + + public void readNE() { + n = 0; + e = 0; + while (scan.hasNext() == true) { + tmpChar = scan.next().charAt(0); + if (tmpChar == 'n') { + n++; + } + if (tmpChar == 'e') { + e++; + } + } + readFile(); + } + + public void make() { + readFile(); + xarr = new int[n];// X Position + yarr = new int[n];// Y Position + earr = new int[e][3];// [x][y]; x:Wert, y:0=xPos, 1=yPos, 2=Abstand + for (int i = 0; i < n; i++) { + scan.next(); + xarr[i] = scan.nextInt(); + yarr[i] = scan.nextInt(); + } + for (int i = 0; i < e; i++) { + scan.next(); + earr[i][0] = scan.nextInt();// Start + earr[i][1] = scan.nextInt();// Ziel + earr[i][2] = scan.nextInt();// Entfernung + } + readFile(); + } + + public void paint(Graphics g) { + labAnzeigen(g); + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigen(Graphics g) { + labAnzeigen(g); + } + + public void labAnzeigen(Graphics g) { + g.clearRect(0, 0, 800, 800);// Feld clearen + g.setColor(new Color(200, 10, 100));// Farbe setzen + for (int i = 0; i < n; i++) { + g.fillOval(xarr[i], yarr[i], 36, 36);// Punkt fur Stadt erstellen + g.setColor(new Color(0, 0, 0)); + g.drawString(Integer.toString(i), xarr[i] + 14, yarr[i] + 22);// Stadt bezeichnen + g.setColor(new Color(200, 10, 100)); + } + for (int i = 0; i < e; i++) { + g.drawLine(xarr[earr[i][0]] + 16, yarr[earr[i][0]] + 16, xarr[earr[i][1]] + 16, yarr[earr[i][1]] + 16);// linie + // zwischen + // zwei + // Punkten + } + for (int i = 0; i < e; i++) { + g.setColor(new Color(100, 255, 100)); + g.drawString(Integer.toString(earr[i][2]), (xarr[earr[i][0]] + xarr[earr[i][1]]) / 2 + 10, + (yarr[earr[i][0]] + yarr[earr[i][1]]) / 2 + 20);// zeichnung der Linie + g.setColor(new Color(200, 10, 100)); + } + } +} diff --git a/Dijkstra_vs/input.txt b/Dijkstra_vs/input.txt new file mode 100644 index 0000000..98978a4 --- /dev/null +++ b/Dijkstra_vs/input.txt @@ -0,0 +1,15 @@ +n 100 250 +n 266 100 +n 266 400 +n 433 100 +n 433 300 +n 600 250 +e 2 4 33 +e 3 5 2 +e 3 4 20 +e 4 5 1 +e 2 3 20 +e 1 4 10 +e 1 3 50 +e 0 2 20 +e 0 1 10 diff --git a/Dijkstra_vs/input2.txt b/Dijkstra_vs/input2.txt new file mode 100644 index 0000000..4062929 --- /dev/null +++ b/Dijkstra_vs/input2.txt @@ -0,0 +1,14 @@ +n 100 250 +n 200 250 +n 350 100 +n 350 400 +n 500 250 +n 600 250 +e 0 1 10 +e 1 2 1 +e 2 4 3 +e 4 3 10 +e 3 1 4 +e 4 5 22 + + diff --git a/Dijkstra_vs/input3.txt b/Dijkstra_vs/input3.txt new file mode 100644 index 0000000..35d9d6b --- /dev/null +++ b/Dijkstra_vs/input3.txt @@ -0,0 +1,39 @@ +n 217 300 +n 403 316 +n 118 60 +n 645 303 +n 402 71 +n 245 234 +n 580 376 +n 448 483 +n 146 366 +n 453 215 +e 0 5 343 +e 1 6 954 +e 1 5 879 +e 2 5 1054 +e 2 4 1364 +e 3 6 433 +e 4 5 1106 +e 8 0 464 +e 0 7 1435 +e 1 7 811 +e 6 7 837 +e 4 9 766 +e 3 9 1053 +e 1 9 524 +e 5 0 343 +e 6 1 954 +e 5 1 879 +e 5 2 1054 +e 4 2 1364 +e 6 3 433 +e 5 4 1106 +e 0 8 464 +e 7 0 1435 +e 7 1 811 +e 7 6 837 +e 9 4 766 +e 9 3 1053 +e 9 1 524 + diff --git a/Dijkstra_vs/yeet.class b/Dijkstra_vs/yeet.class new file mode 100644 index 0000000..602dd0b Binary files /dev/null and b/Dijkstra_vs/yeet.class differ diff --git a/Dijkstra_vs/yeet.java b/Dijkstra_vs/yeet.java new file mode 100644 index 0000000..6a8a6ec --- /dev/null +++ b/Dijkstra_vs/yeet.java @@ -0,0 +1,170 @@ +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; +import javax.swing.*; +import java.awt.*; +import java.lang.Math; +import java.util.Random; +import java.util.*; + +public class yeet extends JFrame { + Scanner scan; + int n, e; // n: Anzahl Punkte, e: Anzahl Wege + String tmpStr1, filename; + int[] xarr, yarr; + int[][] earr; + char tmpChar; + int[] dist; // distanzen + int[][] con; // connections + + public static void main(String[] args) { + if (args.length == 0) { + new yeet(); + } else { + for (int i = 0; i < args.length; i++) { + new yeet(args[i]); + } + } + } + + public yeet() { + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + filename = "input.txt"; + steps(); + } + + public yeet(String input) { + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + filename = input; + steps(); + } + + public void steps() { + readFile(); // einlesen + readNE(); // anzahl von n und e finden. Als int n und e gespeichert + make(); // Arrays erstellen + repaint(); + } + + public void readFile() { + try { + scan = new Scanner(new File(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + } + + public void readNE() { + n = 0; + e = 0; + while (scan.hasNext() == true) { + tmpChar = scan.next().charAt(0); + if (tmpChar == 'n') { + n++; + } + if (tmpChar == 'e') { + e++; + } + } + readFile(); + } + + public void make() { + readFile(); + xarr = new int[n]; // X Position + yarr = new int[n]; // Y Position + earr = new int[e][3]; // [x][y]; x:Wert, y:0=Start, 1=Ziel, 2=Abstand + + for (int i = 0; i < n; i++) { + scan.next(); + xarr[i] = scan.nextInt(); + yarr[i] = scan.nextInt(); + } + for (int i = 0; i < e; i++) { + scan.next(); + earr[i][0] = scan.nextInt();// Start + earr[i][1] = scan.nextInt();// Ziel + earr[i][2] = scan.nextInt();// Entfernung + } + readFile(); + } + + public int[] qwerty(int node) { + dist = new int[n]; // kurzeste Distanz von 0 zu Punkt i + int boi = 0; + for (int r = 0; r < n; r++) { + if (conn(node, r)) { + boi++; + } + } + int[] out; + out = new int[boi]; + int boii = 0; + for (int r = 0; r < n; r++) { + if (conn(node, r)) { + out[boii] = r; + } + } + + return out; + } + + public boolean conn(int input, int input2) { + boolean fish = false; + for (int i = 0; i < n; i++) { + if (earr[i][0] == input && earr[i][1] == input2) { + fish = true; + } + if (earr[i][0] == input2 && earr[i][1] == input) { + fish = true; + } + + } + return fish; + } + + public int distance(int input, int input2) { + for (int i = 0; i < n; i++) { + if (earr[i][0] == input && earr[i][1] == input2) { + return earr[i][2]; + } + if (earr[i][0] == input2 && earr[i][1] == input) { + return earr[i][2]; + } + } + return 0; + } + + public void paint(Graphics g) { + labAnzeigen(g); + } + + public void labAnzeigen(Graphics g) { + g.clearRect(0, 0, 800, 800); // Feld clearen + g.setColor(new Color(200, 10, 100)); // Farbe setzen + for (int i = 0; i < n; i++) { + g.fillOval(xarr[i], yarr[i], 36, 36); // Punkt fur Stadt erstellen + g.setColor(new Color(0, 0, 0)); + g.drawString(Integer.toString(i), xarr[i] + 14, yarr[i] + 22); // Stadt bezeichnen + g.setColor(new Color(200, 10, 100)); + } + for (int i = 0; i < e; i++) { + g.drawLine(xarr[earr[i][0]] + 16, yarr[earr[i][0]] + 16, xarr[earr[i][1]] + 16, yarr[earr[i][1]] + 16); // linie + } + for (int i = 0; i < e; i++) { + g.setColor(new Color(100, 255, 100)); + g.drawString(Integer.toString(earr[i][2]), (xarr[earr[i][0]] + xarr[earr[i][1]]) / 2 + 10, + (yarr[earr[i][0]] + yarr[earr[i][1]]) / 2 + 20); // zeichnung der Linie + g.setColor(new Color(200, 10, 100)); + } + } +} diff --git a/TillsKakProjekt_noBlueJ/README.TXT b/TillsKakProjekt_noBlueJ/README.TXT new file mode 100644 index 0000000..7342ea5 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/README.TXT @@ -0,0 +1,12 @@ +------------------------------------------------------------------------ +This is the project README file. Here, you should describe your project. +Tell the reader (someone who does not know anything about this project) +all they need to know. The comments should usually include at least: +------------------------------------------------------------------------ + +PROJECT TITLE: +PURPOSE OF PROJECT: +VERSION or DATE: +HOW TO START THIS PROJECT: +AUTHORS: +USER INSTRUCTIONS: diff --git a/TillsKakProjekt_noBlueJ/execute.sh b/TillsKakProjekt_noBlueJ/execute.sh new file mode 100644 index 0000000..137f362 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/execute.sh @@ -0,0 +1,3 @@ +#! /usr/bin/bash +javac rotation.java +java rotation diff --git a/TillsKakProjekt_noBlueJ/file1.txt b/TillsKakProjekt_noBlueJ/file1.txt new file mode 100644 index 0000000..acbd2c1 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/file1.txt @@ -0,0 +1,6 @@ +5 +##### +# 00# +#1 2# +#1 2# +## ## diff --git a/TillsKakProjekt_noBlueJ/file2.txt b/TillsKakProjekt_noBlueJ/file2.txt new file mode 100644 index 0000000..cf91efe --- /dev/null +++ b/TillsKakProjekt_noBlueJ/file2.txt @@ -0,0 +1,9 @@ +8 +######## +# 0# +# 0# +#112222# +#33 4# +#55 4# +#666 4# +### #### diff --git a/TillsKakProjekt_noBlueJ/file3.txt b/TillsKakProjekt_noBlueJ/file3.txt new file mode 100644 index 0000000..bef8908 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/file3.txt @@ -0,0 +1,11 @@ +10 +########## +# # +# # +# # +# 7775# +# 11 5# +# 2 888# +#990233 # +#44066666# +##### #### diff --git a/TillsKakProjekt_noBlueJ/file4.txt b/TillsKakProjekt_noBlueJ/file4.txt new file mode 100644 index 0000000..6f89571 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/file4.txt @@ -0,0 +1,13 @@ +12 +############ +# # +# 01 # +# 01 # +# 01 # +# 222222# +# 34 5 # +# 34 5 # +# 634 5 # +# 63477775 # +# 63888885 # +###### ##### diff --git a/TillsKakProjekt_noBlueJ/package.bluej b/TillsKakProjekt_noBlueJ/package.bluej new file mode 100644 index 0000000..6835843 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/package.bluej @@ -0,0 +1,32 @@ +#BlueJ package file +editor.fx.0.height=1396 +editor.fx.0.width=2160 +editor.fx.0.x=0 +editor.fx.0.y=0 +objectbench.height=94 +objectbench.width=776 +package.divider.horizontal=0.6 +package.divider.vertical=0.8003952569169961 +package.editor.height=398 +package.editor.width=670 +package.editor.x=125 +package.editor.y=598 +package.frame.height=600 +package.frame.width=800 +package.numDependencies=0 +package.numTargets=1 +package.showExtends=true +package.showUses=true +project.charset=UTF-8 +readme.height=60 +readme.name=@README +readme.width=49 +readme.x=10 +readme.y=10 +target1.height=70 +target1.name=rotation +target1.showInterface=false +target1.type=ClassTarget +target1.width=120 +target1.x=134 +target1.y=90 diff --git a/TillsKakProjekt_noBlueJ/r.sh b/TillsKakProjekt_noBlueJ/r.sh new file mode 100644 index 0000000..137f362 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/r.sh @@ -0,0 +1,3 @@ +#! /usr/bin/bash +javac rotation.java +java rotation diff --git a/TillsKakProjekt_noBlueJ/rotation.class b/TillsKakProjekt_noBlueJ/rotation.class new file mode 100644 index 0000000..6c694a7 Binary files /dev/null and b/TillsKakProjekt_noBlueJ/rotation.class differ diff --git a/TillsKakProjekt_noBlueJ/rotation.ctxt b/TillsKakProjekt_noBlueJ/rotation.ctxt new file mode 100644 index 0000000..5f1fbc1 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/rotation.ctxt @@ -0,0 +1,39 @@ +#BlueJ class context +comment0.target=rotation +comment1.params= +comment1.target=rotation() +comment10.params=pX\ pY\ block +comment10.target=void\ fallV(int,\ int,\ int) +comment11.params=input +comment11.target=void\ delete(int) +comment12.params=g +comment12.target=void\ paint(java.awt.Graphics) +comment13.params= +comment13.target=void\ neuzeichnen() +comment14.params=g +comment14.target=void\ anzeigen(java.awt.Graphics) +comment15.params=g +comment15.target=void\ feldAnzeigen(java.awt.Graphics) +comment16.params= +comment16.target=void\ anzeigenTxt() +comment17.params=milliseconds +comment17.target=void\ wait(int) +comment18.params= +comment18.target=void\ rotateClockwise() +comment2.params= +comment2.target=void\ rd() +comment3.params= +comment3.target=void\ ld() +comment4.params= +comment4.target=void\ richten() +comment5.params= +comment5.target=void\ checkFall() +comment6.params=px\ py +comment6.target=boolean\ movedBlocks(int,\ int) +comment7.params=pX\ pY\ block +comment7.target=void\ fall(int,\ int,\ int) +comment8.params=pX\ pY\ block +comment8.target=boolean\ horizontal(int,\ int,\ int) +comment9.params=pX\ pY\ block +comment9.target=void\ fallH(int,\ int,\ int) +numComments=19 diff --git a/TillsKakProjekt_noBlueJ/rotation.java b/TillsKakProjekt_noBlueJ/rotation.java new file mode 100644 index 0000000..fb366f0 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/rotation.java @@ -0,0 +1,404 @@ +import javax.swing.*; +import java.awt.*; +import java.util.*; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.ArrayList; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class rotation extends JFrame implements KeyListener { + int feldGroesse; + int[][] feld; + private int ppX, len; // laengen und tmp ints + public boolean cheggin, moved, canMove, solved; + public static String filename; + + ArrayList mBlocks = new ArrayList(); + ArrayList arraylist = new ArrayList(); + + public static void main(String[] args) { + if (args.length != 0) { + new rotation(args[0]); + } else { + new rotation("file1.txt"); + } + + } + + public rotation(String pFilename) { + filename = pFilename; + einlesen(); + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + addKeyListener(this); + anzeigenTxt(); + richten(); + findZiel(); + + // i = feld.length; + // j = feld[0].length; + + } + + public void rd() { + + rotateClockwise(); + checkFall(); + } + + public void ld() { + + // TODO: BS + rotateClockwise(); + rotateClockwise(); + rotateClockwise(); + checkFall(); + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if (e.getKeyChar() == 'a') { + ld(); + } + if (e.getKeyChar() == 'd') { + rd(); + } + if (e.getKeyChar() == 's') { + solve(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + public void findZiel() { + + for (int i = 0; i < feld.length; i++) + if (feld[i][feld.length - 1] == 0) { + feld[i][feld.length - 1] = -2; + } + + } + + public void richten() { + + rotateClockwise(); + + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + matrixNeu[m][l] = feld[feld.length - 1 - m][l]; + } + } + feld = matrixNeu; + repaint(); + } + + public void solve() { + solved = false; + while (!solved) { + if (Math.random() > 0.5) { + rd(); + System.out.println("rechts"); + } else { + ld(); + System.out.println("links"); + } + repaint(); + wait(10); + + } + + } + + public void checkFall() { + + moved = false; + + // while(moved == false){ + mBlocks.clear(); + for (int y = 0; y < feld.length; y++) { + for (int x = 0; x < feld.length; x++) { + if (feld[x][y] > 0 && movedBlocks(x, y) == false) { + mBlocks.add(feld[x][y]); + fall(x, y, feld[x][y]); + repaint(); + // System.out.println("yeet"); + } + } + } + // } + } + + public boolean movedBlocks(int px, int py) { + // DONE check array-list, ob zahl schon abgefragt wurde + if (mBlocks.contains(feld[px][py])) { + return true; + } else { + return false; + } + } + + public void fall(int pX, int pY, int block) { + if (horizontal(pX, pY, block) == true) { + fallH(pX, pY, block); + } else { + fallV(pX, pY, block); + } + } + + public boolean horizontal(int pX, int pY, int block) { + if (feld[pX + 1][pY] == block) { + return true; + } else { + return false; + } + } + + public void fallH(int pX, int pY, int block) { + ppX = pX; + len = 0; + + while (feld[ppX][pY] == block) { + // System.out.println("ppX" + ppX + "py" + pY + "block" + block); + len++; + ppX++; + } + + canMove = true; + + for (int i = 0; i < len; i++) { + if (feld[pX + i][pY + 1] != 0) { + canMove = false; + } + } + + if (canMove == true) { + moved = true; + for (int i = 0; i < len; i++) { + feld[pX + i][pY + 1] = block; + feld[pX + i][pY] = 0; + + } + checkFall(); + return; + } + } + + public void fallV(int pX, int pY, int block) { + cheggin = true; + int i = 0; + int ppY = pY; + + while (cheggin == true) { + + if (feld[pX][ppY] != block) { + cheggin = false; + } else { + ppY++; + } + } + // TODO siegesabfrage + // System.out.println("ppy:" + ppY + "px:" + pX); + + if (feld[pX][ppY] == -2) { + solved = true; + delete(block); + } + + if (feld[pX][ppY] == 0) { + for (int j = ppY; j > pY; j--) { + feld[pX][j] = feld[pX][j - 1]; + feld[pX][j - 1] = 0; + + } + moved = true; + checkFall(); + return; + } else { + return; + } + } + + public void delete(int input) { + + int[][] matrixNeu = new int[feld.length][feld.length]; + matrixNeu = feld; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + if (matrixNeu[m][l] == input) { + matrixNeu[m][l] = 0; + + } + } + } + feld = matrixNeu; + repaint(); + } + + public void auslesen(String pString, int index) { + for (int i = 0; i < feldGroesse; i++) { + String pos = pString.substring(i, i + 1); + System.out.print(pos + ","); + + // System.out.println("i: " + i + " index: " + index); + + if (pos.equals("#")) { + feld[index][i] = -2; + } else if (pos.equals(" ")) { + feld[index][i] = -1; + } else + feld[index][i] = Integer.parseInt(pos); + feld[index][i]++; + } + // System.out.println(); + } + + public void einlesen() { + try { + ArrayList arrayTxtDatei1 = new ArrayList(); + FileReader f = new FileReader(filename); + BufferedReader br = new BufferedReader(f); + + String zeile = br.readLine(); + System.out.println("Erste Zeile: " + zeile); + // Feld initialisieren + feldGroesse = Integer.parseInt(zeile); + + feld = new int[feldGroesse][feldGroesse]; + + System.out.println("Feldgroesse ist: [" + feldGroesse + "][" + feldGroesse + "]"); + + int index = 0; + + while (zeile != null && index < feldGroesse) { + // System.out.println("file1.txt " + zeile); + + // arrayTxtDatei1.add(Integer.valueOf(zeile)); + + zeile = br.readLine(); + auslesen(zeile, index); + index++; + + } + br.close(); + } + + catch (IOException e) { + e.printStackTrace(); + } + + Integer array[] = new Integer[arraylist.size()]; + array = arraylist.toArray(array); + } + + public void paint(Graphics g) { + feldAnzeigen(g); + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigen(Graphics g) { + + feldAnzeigen(g); + } + + public void feldAnzeigen(Graphics g) { + + for (int j = 0; j < feld.length; j++) { + for (int i = 0; i < feld.length; i++) { + + if (feld[j][i] == 0) { + g.setColor(new Color(255, 255, 255)); + } + if (feld[j][i] == -1) { + g.setColor(new Color(100, 100, 100)); + } + if (feld[j][i] == 1) { + g.setColor(new Color(255, 0, 0)); + } + if (feld[j][i] == 2) { + g.setColor(new Color(0, 255, 0)); + } + if (feld[j][i] == 3) { + g.setColor(new Color(0, 0, 255)); + } + if (feld[j][i] == 4) { + g.setColor(new Color(255, 0, 255)); + } + if (feld[j][i] == 5) { + g.setColor(new Color(0, 255, 255)); + } + if (feld[j][i] == 6) { + g.setColor(new Color(138, 43, 226)); + } + if (feld[j][i] == 7) { + g.setColor(new Color(147, 112, 219)); + } + if (feld[j][i] == 8) { + g.setColor(new Color(255, 140, 0)); + } + if (feld[j][i] == 9) { + g.setColor(new Color(0, 100, 0)); + } + if (feld[j][i] == 10) { + g.setColor(new Color(151, 255, 255)); + } + if (feld[j][i] == -2) { + g.setColor(new Color(255, 255, 0)); + } + g.fillRect(100 + 21 * j, 100 + 21 * i, 20, 20); + } + } + } + + public void anzeigenTxt() { + + for (int xpos = 0; xpos < feld.length; xpos++) { + + for (int ypos = 0; ypos < feld[0].length; ypos++) { + System.out.print(feld[ypos][xpos] + " \t"); + } + + System.out.println(); + } + } + + public void wait(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (Exception e) { + // ignoring exception at the moment + } + } + + void rotateClockwise() { + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + // matrixNeu[k][i-l]=feld[i][j]; + matrixNeu[feld.length - 1 - m][l] = feld[l][m]; + + } + } + feld = matrixNeu; + repaint(); + } +} diff --git a/TillsKakProjekt_noBlueJ/rotation_bu.java b/TillsKakProjekt_noBlueJ/rotation_bu.java new file mode 100644 index 0000000..4b3deb7 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/rotation_bu.java @@ -0,0 +1,347 @@ + + +import javax.swing.*; +import java.awt.*; +import java.util.Random; +import java.util.ArrayList; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Scanner; +import java.io.*; + + +public class rotation extends JFrame implements KeyListener +{ + +private int feld[][]= //Feld... duh + + {{-1, -1, -1, -1, -1 }, //-1=wand, 0=leeres feld, 1-3=bloecke, -2=ausgang + { -1, 0, 1, 1, -1 }, + { -1, 2, 0, 3, -1 }, + { -1, 2, 0, 3, -1 }, + { -1, -1, -2, -1, -1 }}; + +private int fl=feld.length, ppX, len; //laengen und tmp ints +public boolean cheggin, moved, canMove; +Scanner scan; +public static String filename; + + +ArrayList mBlocks = new ArrayList(); + +public static void main(String[] args){ + if(args.length!=0){ + filename=args[0]; + } + new rotation(); + + +} + + +@Override +public void keyTyped(KeyEvent e) { + +} + +@Override +public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if(e.getKeyChar()=='a'){ + ld(); + } + if(e.getKeyChar()=='d'){ + rd(); + } +} + +@Override +public void keyReleased(KeyEvent e) { + +} + +public void readFile(String filename){ + try{ + scan = new Scanner(new File(filename)); + } + catch (FileNotFoundException e){ + e.printStackTrace(); + } +} + +public rotation() { + + setSize(800,800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + anzeigenTxt(); + setBackground(new Color(0,0,0)); + addKeyListener(this); + richten(); +} + + + +public void rd() { + + rotateClockwise(); + checkFall(); + +} + +public void ld() { + + //TODO: BS + rotateClockwise(); + rotateClockwise(); + rotateClockwise(); + checkFall(); + +} + + +public void richten(){ + + rotateClockwise(); + + int[][] matrixNeu= new int[feld.length][feld.length]; + for(int m = 0;m < 5; m++) + { + for(int l = 0; l < 5;l++) + { + matrixNeu[m][l] = feld[fl-1-m][l]; + } + } + feld=matrixNeu; + repaint(); +} + + +public void checkFall(){ + + + moved = false; + + mBlocks.clear(); + for(int y=0;y0 && movedBlocks(x,y)==false){ + mBlocks.add(feld[x][y]); + fall(x,y,feld[x][y]); + repaint(); + //System.out.println("yeet"); + } + } + } + +} + +public boolean movedBlocks(int px, int py){ + //DONE check array-list, ob zahl schon abgefragt wurde + if(mBlocks.contains(feld[px][py])){ + return true; + } + else{ + return false; + } +} + +public void fall(int pX,int pY,int block){ + if(horizontal(pX,pY,block)==true){ + fallH(pX,pY,block); + } + else{ + fallV(pX,pY,block); + } +} + + +public boolean horizontal(int pX,int pY,int block){ + if(feld[pX+1][pY]==block){ + return true; + } + else{ + return false; + } +} + + +public void fallH(int pX,int pY,int block){ + ppX = pX; + len = 0; + + + while(feld[ppX][pY]==block){ + //System.out.println("ppX"+ppX+"py"+pY+"block"+block); + len++; + ppX++; + } + + canMove = true; + + for(int i = 0;ipY;j--){ + feld[pX][j]=feld[pX][j-1]; + feld[pX][j-1]=0; + wait(100); + } + + checkFall(); + return; + } + else{ + return; + } + +} + + +public void delete(int input){ + + int[][] matrixNeu= new int[feld.length][feld.length]; + matrixNeu = feld; + for(int m=0;m < fl; m++) + { + for(int l=0;l< fl;l++) + { + if(matrixNeu[m][l] == input){ + matrixNeu[m][l] = 0; + wait(50); + } + } + } + feld=matrixNeu; + repaint(); +} + + +public void paint(Graphics g) +{ + feldAnzeigen(g); +} + +public void neuzeichnen() +{ + repaint(); +} + +public void anzeigen(Graphics g) +{ + feldAnzeigen(g); +} + +public void feldAnzeigen(Graphics g) +{ + + for(int j=0;j < 5; j++) + { + for(int i=0;i< 5;i++) + { + + if(feld[j][i] == 0){ + g.setColor(new Color(255,255,255)); + } + if(feld[j][i] == -1){ + g.setColor(new Color(100,100,100)); + } + if(feld[j][i] == 1){ + g.setColor(new Color(255,0,0)); + } + if(feld[j][i] == 2){ + g.setColor(new Color(0,255,0)); + } + if(feld[j][i] == 3){ + g.setColor(new Color(0,0,255)); + } + if(feld[j][i] == -2){ + g.setColor(new Color(255,215,0)); + } + g.fillRect(100+42*j ,100+42*i ,40, 40); + } + } +} + +public void anzeigenTxt() +{ + + for (int xpos=0;xpos mBlocks = new ArrayList(); + + public static void main(String[] args) { + if (args.length != 0) { + filename = args[0]; + } + new rotation(); + + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if (e.getKeyChar() == 'a') { + ld(); + } + if (e.getKeyChar() == 'd') { + rd(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + public void readFile() { + try { + scan = new Scanner(new File(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public void createString() { + + List listOfStrings = new ArrayList(); + + // load the data from file + try { + listOfStrings = Files.readAllLines(Paths.get(filename)); + } catch (IOException e) { + + } + // convert arraylist to array + array = listOfStrings.toArray(new String[0]); + for (int i = 0; i < array.length; i++) { + array[i] = array[i].replace(' ', 'a'); + + } + + System.out.println(array[3]); + } + + public void dimension() { + tmpArray = new String[array.length]; + sArray = new String[array.length][array.length]; + for (int i = 0; i < array.length; i++) { + scan = new Scanner(array[i]).useDelimiter("\\s*\\s*"); + int j = 0; + while (scan.hasNext()) { + tmpArray[j] = scan.next(); + // tmpArray[j] = tmpArray[j].replace("#","-1"); + tmpArray[j] = tmpArray[j].replace("a", "99"); + System.out.println(tmpArray[j]); + j++; + for (int k = 0; k < tmpArray.length; k++) { + System.out.println(tmpArray[k]); + } + } + sArray[i] = tmpArray; + } + System.out.println(sArray[0][0]); + System.out.println(sArray[4][4]); + + for (int x = 0; x < sArray.length; x++) { + for (int y = 0; y < sArray.length; y++) { + if (sArray[y][x] == "#") { + sArray[y][x] = "-1"; + } + } + } + + } + + public void fill() { + + feld = new int[sArray.length][sArray.length]; + for (int x = 0; x < sArray.length; x++) { + for (int y = 0; y < sArray.length; y++) { + feld[y][x] = Integer.parseInt(sArray[y][x]); + System.out.println(feld[y][x]); + + if (feld[y][x] == 99) { + feld[y][x] = 0; + } else if (feld[y][x] >= 0) { + feld[y][x]++; + } + System.out.println(feld[y][x]); + + } + } + + printNew(); + + } + + public void printNew() { + for (int x = 0; x < sArray.length; x++) { + for (int y = 0; y < sArray.length; y++) { + System.out.print(sArray[x][y] + " \t"); + } + System.out.println(); + } + + } + + public rotation() { + + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + // anzeigenTxt(); + setBackground(new Color(0, 0, 0)); + addKeyListener(this); + if (filename != null) { + readFile(); + createString(); + dimension(); + fill(); + } + richten(); + fl = feld.length; + } + + public void rd() { + + rotateClockwise(); + checkFall(); + + } + + public void ld() { + + // TODO: BS + rotateClockwise(); + rotateClockwise(); + rotateClockwise(); + checkFall(); + + } + + public void richten() { + + rotateClockwise(); + fl = feld.length; + + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < 5; m++) { + for (int l = 0; l < 5; l++) { + matrixNeu[m][l] = feld[fl - 1 - m][l]; + } + } + feld = matrixNeu; + repaint(); + } + + public void checkFall() { + + moved = false; + + mBlocks.clear(); + for (int y = 0; y < fl; y++) { + for (int x = 0; x < fl; x++) { + if (feld[x][y] > 0 && movedBlocks(x, y) == false) { + mBlocks.add(feld[x][y]); + fall(x, y, feld[x][y]); + repaint(); + // System.out.println("yeet"); + } + } + } + + } + + public boolean movedBlocks(int px, int py) { + // DONE check array-list, ob zahl schon abgefragt wurde + if (mBlocks.contains(feld[px][py])) { + return true; + } else { + return false; + } + } + + public void fall(int pX, int pY, int block) { + if (horizontal(pX, pY, block) == true) { + fallH(pX, pY, block); + } else { + fallV(pX, pY, block); + } + } + + public boolean horizontal(int pX, int pY, int block) { + if (feld[pX + 1][pY] == block) { + return true; + } else { + return false; + } + } + + public void fallH(int pX, int pY, int block) { + ppX = pX; + len = 0; + + while (feld[ppX][pY] == block) { + // System.out.println("ppX"+ppX+"py"+pY+"block"+block); + len++; + ppX++; + } + + canMove = true; + + for (int i = 0; i < len; i++) { + if (feld[pX + i][pY + 1] != 0) { + canMove = false; + } + } + + if (canMove == true) { + for (int i = 0; i < len; i++) { + feld[pX + i][pY + 1] = block; + feld[pX + i][pY] = 0; + wait(100); + repaint(); + } + checkFall(); + return; + } + + } + + public void fallV(int pX, int pY, int block) { + cheggin = true; + int i = 0; + int ppY = pY; + + while (cheggin == true) { + + if (feld[pX][ppY] != block) { + cheggin = false; + } else { + ppY++; + } + } + // DONE siegesabfrage + // System.out.println("ppy:"+ppY+"px:"+pX); + + if (feld[pX][ppY] == -2) { + delete(block); + } + + if (feld[pX][ppY] == 0) { + for (int j = ppY; j > pY; j--) { + feld[pX][j] = feld[pX][j - 1]; + feld[pX][j - 1] = 0; + wait(100); + repaint(); + } + + checkFall(); + return; + } else { + return; + } + + } + + public void delete(int input) { + + int[][] matrixNeu = new int[feld.length][feld.length]; + matrixNeu = feld; + for (int m = 0; m < fl; m++) { + for (int l = 0; l < fl; l++) { + if (matrixNeu[m][l] == input) { + matrixNeu[m][l] = 0; + wait(50); + } + } + } + feld = matrixNeu; + repaint(); + } + + public void paint(Graphics g) { + feldAnzeigen(g); + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigen(Graphics g) { + feldAnzeigen(g); + } + + public void feldAnzeigen(Graphics g) { + + for (int j = 0; j < 5; j++) { + for (int i = 0; i < 5; i++) { + + if (feld[j][i] == 0) { + g.setColor(new Color(255, 255, 255)); + } + if (feld[j][i] == -1) { + g.setColor(new Color(100, 100, 100)); + } + if (feld[j][i] == 1) { + g.setColor(new Color(255, 0, 0)); + } + if (feld[j][i] == 2) { + g.setColor(new Color(0, 255, 0)); + } + if (feld[j][i] == 3) { + g.setColor(new Color(0, 0, 255)); + } + if (feld[j][i] == -2) { + g.setColor(new Color(255, 215, 0)); + } + g.fillRect(100 + 42 * j, 100 + 42 * i, 40, 40); + } + } + } + + public void anzeigenTxt() { + + for (int xpos = 0; xpos < feld.length; xpos++) { + + for (int ypos = 0; ypos < feld[0].length; ypos++) { + System.out.println(feld[xpos][ypos] + " x:" + xpos + " y:" + ypos); + } + + } + } + + public void wait(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (Exception e) { + // ignoring exception at the moment + } + } + + void rotateClockwise() { + + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < 5; m++) { + for (int l = 0; l < 5; l++) { + matrixNeu[feld.length - 1 - m][l] = feld[l][m]; + + } + } + feld = matrixNeu; + repaint(); + } + +} diff --git a/TillsKakProjekt_noBlueJ/test2/file1.txt b/TillsKakProjekt_noBlueJ/test2/file1.txt new file mode 100644 index 0000000..d6d1f22 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test2/file1.txt @@ -0,0 +1,5 @@ +##### +# 00# +#1 2# +#1 2# +## ## \ No newline at end of file diff --git a/TillsKakProjekt_noBlueJ/test2/file2.txt b/TillsKakProjekt_noBlueJ/test2/file2.txt new file mode 100644 index 0000000..e2f17be --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test2/file2.txt @@ -0,0 +1,8 @@ +######## +# 0# +# 0# +#112222# +#33 4# +#55 4# +#666 4# +### #### \ No newline at end of file diff --git a/TillsKakProjekt_noBlueJ/test2/file3.txt b/TillsKakProjekt_noBlueJ/test2/file3.txt new file mode 100644 index 0000000..ae220f3 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test2/file3.txt @@ -0,0 +1,10 @@ +########## +# # +# # +# # +# 7775# +# 11 5# +# 2 888# +#990233 # +#44066666# +##### #### \ No newline at end of file diff --git a/TillsKakProjekt_noBlueJ/test2/file4.txt b/TillsKakProjekt_noBlueJ/test2/file4.txt new file mode 100644 index 0000000..26aaaa6 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test2/file4.txt @@ -0,0 +1,12 @@ +############ +# # +# 01 # +# 01 # +# 01 # +# 222222# +# 34 5 # +# 34 5 # +# 634 5 # +# 63477775 # +# 63888885 # +###### ##### \ No newline at end of file diff --git a/TillsKakProjekt_noBlueJ/test2/rotation.class b/TillsKakProjekt_noBlueJ/test2/rotation.class new file mode 100644 index 0000000..97b8ed9 Binary files /dev/null and b/TillsKakProjekt_noBlueJ/test2/rotation.class differ diff --git a/TillsKakProjekt_noBlueJ/test2/rotation.java b/TillsKakProjekt_noBlueJ/test2/rotation.java new file mode 100644 index 0000000..7a59e6f --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test2/rotation.java @@ -0,0 +1,371 @@ + +import javax.swing.*; +import java.awt.*; +import java.util.Random; +import java.util.ArrayList; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Scanner; +import java.io.*; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +public class rotation extends JFrame implements KeyListener { + + public int feld[][]; + /* + * private int feld[][] = // Feld... duh + * + * { { -1, -1, -1, -1, -1 }, // -1=wand, 0=leeres feld, 1-3=bloecke, -2=ausgang + * { -1, 0, 1, 1, -1 }, + * { -1, 2, 0, 3, -1 }, + * { -1, 2, 0, 3, -1 }, + * { -1, -1, -2, -1, -1 } }; + */ + private int ppX, len; // laengen und tmp ints + public boolean cheggin, moved, canMove; + Scanner scan; + public static String filename = "file2.txt"; + public int[][] feld2; + + int feldGroesse; + + ArrayList arraylist = new ArrayList(); + + ArrayList mBlocks = new ArrayList(); + + public static void main(String[] args) { + if (args.length != 0) { + filename = args[0]; + } + new rotation(); + + } + + public rotation() { + + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + // anzeigenTxt(); + setBackground(new Color(0, 0, 0)); + addKeyListener(this); + if (filename != null) { + System.out.print("einlesen"); + einlesen(); + System.out.print("auslesen"); + } + richten(); + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if (e.getKeyChar() == 'a') { + ld(); + } + if (e.getKeyChar() == 'd') { + rd(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + public void auslesen(String pString, int index) { + for (int i = 0; i < feldGroesse; i++) { + String pos = pString.substring(i, i + 1); + System.out.print(pos + ","); + + System.out.println("i: " + i + " index: " + index); + + if (pos.equals("#")) { + feld[index][i] = -2; + } else if (pos.equals(" ")) { + feld[index][i] = -1; + } else + feld[index][i] = Integer.parseInt(pos); + + } + System.out.println(); + } + + public void einlesen() { + + try { + ArrayList arrayTxtDatei1 = new ArrayList(); + FileReader f = new FileReader(filename); + BufferedReader br = new BufferedReader(f); + + String zeile = br.readLine(); + + System.out.println("Erste Zeile: " + zeile); + + // Feld initialisieren + feldGroesse = Integer.parseInt(zeile); + + feld = new int[feldGroesse][feldGroesse]; + + System.out.println("Feldgroesse ist: [" + feldGroesse + "][" + feldGroesse + "]"); + + int index = 0; + + while (zeile != null && index < feldGroesse) { + // System.out.println("file1.txt " + zeile); + + // arrayTxtDatei1.add(Integer.valueOf(zeile)); + + zeile = br.readLine(); + auslesen(zeile, index); + index++; + + } + br.close(); + } + + catch (IOException e) { + e.printStackTrace(); + } + + Integer array[] = new Integer[arraylist.size()]; + array = arraylist.toArray(array); + } + + public void rd() { + + rotateClockwise(); + checkFall(); + + } + + public void ld() { + + // TODO: BS + rotateClockwise(); + rotateClockwise(); + rotateClockwise(); + checkFall(); + + } + + public void richten() { + + rotateClockwise(); + + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < 5; m++) { + for (int l = 0; l < 5; l++) { + matrixNeu[m][l] = feld[feld.length - 1 - m][l]; + } + } + feld = matrixNeu; + repaint(); + } + + public void checkFall() { + + moved = false; + + mBlocks.clear(); + for (int y = 0; y < feld.length; y++) { + for (int x = 0; x < feld.length; x++) { + if (feld[x][y] > 0 && movedBlocks(x, y) == false) { + mBlocks.add(feld[x][y]); + fall(x, y, feld[x][y]); + repaint(); + // System.out.println("yeet"); + } + } + } + + } + + public boolean movedBlocks(int px, int py) { + // DONE check array-list, ob zahl schon abgefragt wurde + if (mBlocks.contains(feld[px][py])) { + return true; + } else { + return false; + } + } + + public void fall(int pX, int pY, int block) { + if (horizontal(pX, pY, block) == true) { + fallH(pX, pY, block); + } else { + fallV(pX, pY, block); + } + } + + public boolean horizontal(int pX, int pY, int block) { + if (feld[pX + 1][pY] == block) { + return true; + } else { + return false; + } + } + + public void fallH(int pX, int pY, int block) { + ppX = pX; + len = 0; + + while (feld[ppX][pY] == block) { + // System.out.println("ppX"+ppX+"py"+pY+"block"+block); + len++; + ppX++; + } + + canMove = true; + + for (int i = 0; i < len; i++) { + if (feld[pX + i][pY + 1] != 0) { + canMove = false; + } + } + + if (canMove == true) { + for (int i = 0; i < len; i++) { + feld[pX + i][pY + 1] = block; + feld[pX + i][pY] = 0; + wait(100); + } + checkFall(); + return; + } + + } + + public void fallV(int pX, int pY, int block) { + cheggin = true; + int i = 0; + int ppY = pY; + + while (cheggin == true) { + + if (feld[pX][ppY] != block) { + cheggin = false; + } else { + ppY++; + } + } + // DONE siegesabfrage + // System.out.println("ppy:"+ppY+"px:"+pX); + + if (feld[pX][ppY] == -2) { + delete(block); + } + + if (feld[pX][ppY] == 0) { + for (int j = ppY; j > pY; j--) { + feld[pX][j] = feld[pX][j - 1]; + feld[pX][j - 1] = 0; + wait(100); + } + + checkFall(); + return; + } else { + return; + } + + } + + public void delete(int input) { + + int[][] matrixNeu = new int[feld.length][feld.length]; + matrixNeu = feld; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + if (matrixNeu[m][l] == input) { + matrixNeu[m][l] = 0; + wait(50); + } + } + } + feld = matrixNeu; + repaint(); + } + + public void paint(Graphics g) { + feldAnzeigen(g); + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigen(Graphics g) { + feldAnzeigen(g); + } + + public void feldAnzeigen(Graphics g) { + + for (int j = 0; j < 5; j++) { + for (int i = 0; i < 5; i++) { + + if (feld[j][i] == 0) { + g.setColor(new Color(255, 255, 255)); + } + if (feld[j][i] == -1) { + g.setColor(new Color(100, 100, 100)); + } + if (feld[j][i] == 1) { + g.setColor(new Color(255, 0, 0)); + } + if (feld[j][i] == 2) { + g.setColor(new Color(0, 255, 0)); + } + if (feld[j][i] == 3) { + g.setColor(new Color(0, 0, 255)); + } + if (feld[j][i] == -2) { + g.setColor(new Color(255, 215, 0)); + } + g.fillRect(100 + 42 * j, 100 + 42 * i, 40, 40); + } + } + } + + public void anzeigenTxt() { + + for (int xpos = 0; xpos < feld2.length; xpos++) { + + for (int ypos = 0; ypos < feld2[0].length; ypos++) { + System.out.print(feld2[xpos][ypos] + " \t"); + } + + System.out.println(); + } + } + + public void wait(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (Exception e) { + // ignoring exception at the moment + } + } + + void rotateClockwise() { + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < 5; m++) { + for (int l = 0; l < 5; l++) { + matrixNeu[feld.length - 1 - m][l] = feld[l][m]; + + } + } + feld = matrixNeu; + repaint(); + } + +} diff --git a/TillsKakProjekt_noBlueJ/test3/file1.txt b/TillsKakProjekt_noBlueJ/test3/file1.txt new file mode 100644 index 0000000..d6d1f22 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test3/file1.txt @@ -0,0 +1,5 @@ +##### +# 00# +#1 2# +#1 2# +## ## \ No newline at end of file diff --git a/TillsKakProjekt_noBlueJ/test3/file2.txt b/TillsKakProjekt_noBlueJ/test3/file2.txt new file mode 100644 index 0000000..cf91efe --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test3/file2.txt @@ -0,0 +1,9 @@ +8 +######## +# 0# +# 0# +#112222# +#33 4# +#55 4# +#666 4# +### #### diff --git a/TillsKakProjekt_noBlueJ/test3/file3.txt b/TillsKakProjekt_noBlueJ/test3/file3.txt new file mode 100644 index 0000000..bef8908 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test3/file3.txt @@ -0,0 +1,11 @@ +10 +########## +# # +# # +# # +# 7775# +# 11 5# +# 2 888# +#990233 # +#44066666# +##### #### diff --git a/TillsKakProjekt_noBlueJ/test3/file4.txt b/TillsKakProjekt_noBlueJ/test3/file4.txt new file mode 100644 index 0000000..5169de9 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test3/file4.txt @@ -0,0 +1,14 @@ + +12 +############ +# # +# 01 # +# 01 # +# 01 # +# 222222# +# 34 5 # +# 34 5 # +# 634 5 # +# 63477775 # +# 63888885 # +###### ##### diff --git a/TillsKakProjekt_noBlueJ/test3/rotation.class b/TillsKakProjekt_noBlueJ/test3/rotation.class new file mode 100644 index 0000000..28418b5 Binary files /dev/null and b/TillsKakProjekt_noBlueJ/test3/rotation.class differ diff --git a/TillsKakProjekt_noBlueJ/test3/rotation.java b/TillsKakProjekt_noBlueJ/test3/rotation.java new file mode 100644 index 0000000..6f543d0 --- /dev/null +++ b/TillsKakProjekt_noBlueJ/test3/rotation.java @@ -0,0 +1,374 @@ + +import javax.swing.*; +import java.awt.*; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.ArrayList; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class rotation extends JFrame implements KeyListener { + int feldGroesse; + int[][] feld; + private int ppX, len; // laengen und tmp ints + public boolean cheggin, moved, canMove; + public static String filename; + + ArrayList mBlocks = new ArrayList(); + ArrayList arraylist = new ArrayList(); + + public static void main(String[] args) { + if (args.length != 0) { + filename = args[0]; + } + new rotation(); + + } + + public rotation() { + if (filename == null) { + filename = "file1.txt"; + } + einlesen(); + setSize(800, 800); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + addKeyListener(this); + anzeigenTxt(); + richten(); + findZiel(); + // i = feld.length; + // j = feld[0].length; + + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if (e.getKeyChar() == 'a') { + ld(); + } + if (e.getKeyChar() == 'd') { + rd(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + public void rd() { + + rotateClockwise(); + checkFall(); + } + + public void ld() { + + // TODO: BS + rotateClockwise(); + rotateClockwise(); + rotateClockwise(); + checkFall(); + } + + public void findZiel() { + + for (int i = 0; i < feld.length; i++) + if (feld[i][feld.length - 1] == 0) { + feld[i][feld.length - 1] = -2; + } + } + + public void richten() { + + rotateClockwise(); + + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + matrixNeu[m][l] = feld[feld.length - 1 - m][l]; + } + } + feld = matrixNeu; + repaint(); + } + + public void checkFall() { + + moved = false; + + // while(moved == false){ + mBlocks.clear(); + for (int y = 0; y < feld.length; y++) { + for (int x = 0; x < feld.length; x++) { + if (feld[x][y] > 0 && movedBlocks(x, y) == false) { + mBlocks.add(feld[x][y]); + fall(x, y, feld[x][y]); + repaint(); + System.out.println("yeet"); + } + } + } + // } + } + + public boolean movedBlocks(int px, int py) { + // DONE check array-list, ob zahl schon abgefragt wurde + if (mBlocks.contains(feld[px][py])) { + return true; + } else { + return false; + } + } + + public void fall(int pX, int pY, int block) { + if (horizontal(pX, pY, block) == true) { + fallH(pX, pY, block); + } else { + fallV(pX, pY, block); + } + } + + public boolean horizontal(int pX, int pY, int block) { + if (feld[pX + 1][pY] == block) { + return true; + } else { + return false; + } + } + + public void fallH(int pX, int pY, int block) { + ppX = pX; + len = 0; + + while (feld[ppX][pY] == block) { + System.out.println("ppX" + ppX + "py" + pY + "block" + block); + len++; + ppX++; + } + + canMove = true; + + for (int i = 0; i < len; i++) { + if (feld[pX + i][pY + 1] != 0) { + canMove = false; + } + } + + if (canMove == true) { + moved = true; + for (int i = 0; i < len; i++) { + feld[pX + i][pY + 1] = block; + feld[pX + i][pY] = 0; + + } + checkFall(); + return; + } + } + + public void fallV(int pX, int pY, int block) { + cheggin = true; + int i = 0; + int ppY = pY; + + while (cheggin == true) { + + if (feld[pX][ppY] != block) { + cheggin = false; + } else { + ppY++; + } + } + // TODO siegesabfrage + System.out.println("ppy:" + ppY + "px:" + pX); + + if (feld[pX][ppY] == -2) { + delete(block); + } + + if (feld[pX][ppY] == 0) { + for (int j = ppY; j > pY; j--) { + feld[pX][j] = feld[pX][j - 1]; + feld[pX][j - 1] = 0; + + } + moved = true; + checkFall(); + return; + } else { + return; + } + } + + public void delete(int input) { + + int[][] matrixNeu = new int[feld.length][feld.length]; + matrixNeu = feld; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + if (matrixNeu[m][l] == input) { + matrixNeu[m][l] = 0; + + } + } + } + feld = matrixNeu; + repaint(); + } + + public void auslesen(String pString, int index) { + for (int i = 0; i < feldGroesse; i++) { + String pos = pString.substring(i, i + 1); + System.out.print(pos + ","); + + System.out.println("i: " + i + " index: " + index); + + if (pos.equals("#")) { + feld[index][i] = -2; + } else if (pos.equals(" ")) { + feld[index][i] = -1; + } else + feld[index][i] = Integer.parseInt(pos); + feld[index][i]++; + } + System.out.println(); + } + + public void einlesen() { + try { + ArrayList arrayTxtDatei1 = new ArrayList(); + FileReader f = new FileReader(filename); + BufferedReader br = new BufferedReader(f); + + String zeile = br.readLine(); + System.out.println("Erste Zeile: " + zeile); + // Feld initialisieren + feldGroesse = Integer.parseInt(zeile); + + feld = new int[feldGroesse][feldGroesse]; + + System.out.println("Feldgroesse ist: [" + feldGroesse + "][" + feldGroesse + "]"); + + int index = 0; + + while (zeile != null && index < feldGroesse) { + // System.out.println("file1.txt " + zeile); + + // arrayTxtDatei1.add(Integer.valueOf(zeile)); + + zeile = br.readLine(); + auslesen(zeile, index); + index++; + + } + br.close(); + } + + catch (IOException e) { + e.printStackTrace(); + } + + Integer array[] = new Integer[arraylist.size()]; + array = arraylist.toArray(array); + } + + public void paint(Graphics g) { + feldAnzeigen(g); + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigen(Graphics g) { + + feldAnzeigen(g); + } + + public void feldAnzeigen(Graphics g) { + + for (int j = 0; j < feld.length; j++) { + for (int i = 0; i < feld.length; i++) { + + if (feld[j][i] == 0) { + g.setColor(new Color(255, 255, 255)); + } + if (feld[j][i] == -1) { + g.setColor(new Color(100, 100, 100)); + } + if (feld[j][i] == 1) { + g.setColor(new Color(255, 0, 0)); + } + if (feld[j][i] == 2) { + g.setColor(new Color(0, 255, 0)); + } + if (feld[j][i] == 3) { + g.setColor(new Color(0, 0, 255)); + } + if (feld[j][i] == 4) { + g.setColor(new Color(255, 0, 255)); + } + if (feld[j][i] == 5) { + g.setColor(new Color(0, 255, 255)); + } + if (feld[j][i] == 6) { + g.setColor(new Color(138, 43, 226)); + } + if (feld[j][i] == 7) { + g.setColor(new Color(147, 112, 219)); + } + if (feld[j][i] == -2) { + g.setColor(new Color(255, 255, 0)); + } + g.fillRect(100 + 21 * j, 100 + 21 * i, 20, 20); + } + } + } + + public void anzeigenTxt() { + + for (int xpos = 0; xpos < feld.length; xpos++) { + + for (int ypos = 0; ypos < feld[0].length; ypos++) { + System.out.print(feld[xpos][ypos] + " \t"); + } + + System.out.println(); + } + } + + public void wait(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (Exception e) { + // ignoring exception at the moment + } + } + + void rotateClockwise() { + int[][] matrixNeu = new int[feld.length][feld.length]; + for (int m = 0; m < feld.length; m++) { + for (int l = 0; l < feld.length; l++) { + // matrixNeu[k][i-l]=feld[i][j]; + matrixNeu[feld.length - 1 - m][l] = feld[l][m]; + + } + } + feld = matrixNeu; + repaint(); + } + +} diff --git a/linenSicht/Shape.class b/linenSicht/Shape.class new file mode 100644 index 0000000..d6112ea Binary files /dev/null and b/linenSicht/Shape.class differ diff --git a/linenSicht/Shape.java b/linenSicht/Shape.java new file mode 100644 index 0000000..f50798b --- /dev/null +++ b/linenSicht/Shape.java @@ -0,0 +1,34 @@ + +import javax.swing.*; +import java.awt.*; +import java.util.*; + +public class Shape { + + ArrayList x = new ArrayList(); + ArrayList y = new ArrayList(); + int len = 0; + + public Shape() { + + } + + public void addPoint(int posX, int posY) { + x.add(posX); + y.add(posY); + len++; + + } + + public int getX(int index) { + return x.get(index); + } + + public int getY(int index) { + return y.get(index); + } + + public int getLength() { + return len; + } +} diff --git a/linenSicht/file1.txt b/linenSicht/file1.txt new file mode 100644 index 0000000..f137dab --- /dev/null +++ b/linenSicht/file1.txt @@ -0,0 +1,3 @@ +1 +3 535 410 610 70 460 70 +633 189 diff --git a/linenSicht/file2.txt b/linenSicht/file2.txt new file mode 100644 index 0000000..c62e5cd --- /dev/null +++ b/linenSicht/file2.txt @@ -0,0 +1,5 @@ +3 +4 390 260 505 213 551 329 413 444 +5 410 50 433 50 594 96 525 188 387 165 +5 170 80 193 80 340 150 331 287 170 402 +633 189 diff --git a/linenSicht/file3.txt b/linenSicht/file3.txt new file mode 100644 index 0000000..62f7986 --- /dev/null +++ b/linenSicht/file3.txt @@ -0,0 +1,10 @@ +8 +6 539 98 549 98 599 118 569 158 519 198 489 138 +4 559 178 569 178 609 248 519 238 +8 389 78 459 68 599 68 479 88 459 178 509 248 599 258 499 298 +7 320 98 330 98 370 118 360 158 330 198 300 158 280 118 +7 380 208 390 188 430 208 380 228 390 288 360 248 340 208 +4 352 287 445 305 386 366 291 296 +5 319 18 293 53 365 80 238 73 257 15 +9 637 248 516 330 426 238 462 302 451 350 613 348 761 346 754 231 685 183 +479 168 diff --git a/linenSicht/file4.txt b/linenSicht/file4.txt new file mode 100644 index 0000000..37ccd2c --- /dev/null +++ b/linenSicht/file4.txt @@ -0,0 +1,13 @@ +11 +5 121 39 290 27 284 86 156 110 121 88 +6 133 206 202 144 254 170 278 224 201 194 156 258 +6 160 290 247 301 162 398 365 280 276 253 208 233 +3 170 421 386 298 384 472 +4 408 297 428 297 565 199 413 475 +4 300 120 440 160 382 227 320 201 +3 323 34 440 20 308 85 +3 500 20 500 140 376 103 +8 540 20 600 40 600 100 740 100 700 340 660 340 660 140 540 140 +4 580 240 633 402 896 475 508 466 +10 780 140 1020 140 1020 480 960 480 960 200 800 200 773 301 900 300 900 340 740 340 +856 270 diff --git a/linenSicht/file5.txt b/linenSicht/file5.txt new file mode 100644 index 0000000..cf3da3c --- /dev/null +++ b/linenSicht/file5.txt @@ -0,0 +1,14 @@ +12 +4 400 185 650 185 650 255 400 255 +5 497 10 598 19 604 102 549 165 447 141 +7 320 165 380 165 380 285 510 285 510 305 420 305 320 305 +4 300 55 360 45 380 135 320 145 +4 200 35 280 35 280 215 200 215 +5 170 215 300 265 300 325 180 305 150 245 +6 90 35 130 95 170 55 180 155 120 195 70 135 +4 400 125 430 145 410 175 380 155 +4 90 225 140 225 130 265 90 285 +5 540 280 541 280 800 280 800 400 540 400 +10 380 340 381 340 520 340 460 380 540 440 720 460 420 460 140 440 140 300 280 380 +4 80 300 81 300 140 280 120 360 +621 162 diff --git a/linenSicht/sichtlinien$1.class b/linenSicht/sichtlinien$1.class new file mode 100644 index 0000000..1535aa1 Binary files /dev/null and b/linenSicht/sichtlinien$1.class differ diff --git a/linenSicht/sichtlinien$2.class b/linenSicht/sichtlinien$2.class new file mode 100644 index 0000000..21b9c11 Binary files /dev/null and b/linenSicht/sichtlinien$2.class differ diff --git a/linenSicht/sichtlinien$3.class b/linenSicht/sichtlinien$3.class new file mode 100644 index 0000000..aeff049 Binary files /dev/null and b/linenSicht/sichtlinien$3.class differ diff --git a/linenSicht/sichtlinien$Intersect.class b/linenSicht/sichtlinien$Intersect.class new file mode 100644 index 0000000..f68d2ab Binary files /dev/null and b/linenSicht/sichtlinien$Intersect.class differ diff --git a/linenSicht/sichtlinien$MouseManager.class b/linenSicht/sichtlinien$MouseManager.class new file mode 100644 index 0000000..e44c7d4 Binary files /dev/null and b/linenSicht/sichtlinien$MouseManager.class differ diff --git a/linenSicht/sichtlinien$Segment.class b/linenSicht/sichtlinien$Segment.class new file mode 100644 index 0000000..926fb24 Binary files /dev/null and b/linenSicht/sichtlinien$Segment.class differ diff --git a/linenSicht/sichtlinien$Vector.class b/linenSicht/sichtlinien$Vector.class new file mode 100644 index 0000000..050af1c Binary files /dev/null and b/linenSicht/sichtlinien$Vector.class differ diff --git a/linenSicht/sichtlinien.class b/linenSicht/sichtlinien.class new file mode 100644 index 0000000..829607c Binary files /dev/null and b/linenSicht/sichtlinien.class differ diff --git a/linenSicht/sichtlinien.java b/linenSicht/sichtlinien.java new file mode 100644 index 0000000..1d0d92c --- /dev/null +++ b/linenSicht/sichtlinien.java @@ -0,0 +1,469 @@ + +//TODO sterne wegmachen +import javax.swing.*; +import java.awt.*; +import java.util.*; + +import java.util.Random; +import java.util.ArrayList; + +//keys +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +//files +import java.io.FileReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.BufferedReader; +//mouse +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +//refresh +import java.awt.event.ActionEvent; +import javax.swing.Timer; +import java.awt.event.ActionListener; + +public class sichtlinien extends JFrame implements KeyListener { + + public static String filename; + Scanner scan; + Polygon p; + Shape[] shapes = makeArr(); + int amount, startX, startY, HEIGHT = 1100, WIDTH = 1100; + + Timer looper = new Timer(1000 / 60, new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // repaint(); + } + + }); + + boolean first = false, showLines = false; + + Segment[] segments = makeSegments(); + Segment[] rays = createRays(); + + public static void main(String[] args) { + // DONE for-loop fur mehrere inputs + if (args.length != 0) { + for (String arg : args) { + filename = arg; + new sichtlinien(arg); + } + + } else { + filename = "file1.txt"; + new sichtlinien("file1.txt"); + } + + } + + public sichtlinien(String input) { + filename = input; + System.out.println("Before"); + setSize(WIDTH, HEIGHT); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + setVisible(true); + setBackground(new Color(0, 0, 0)); + addKeyListener(this); + JPanel panel = new JPanel(); + add(panel); + panel.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + System.out.println(e.getX() + "," + e.getY()); + startX = e.getX(); + startY = e.getY() - 75; + repaint(); + } + }); + // looper.start(); + repaint(); + + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key: " + e.getKeyChar()); + if (e.getKeyChar() == 'a') { + + } + if (e.getKeyChar() == 'd') { + showLines = false; + repaint(); + } + if (e.getKeyChar() == 's') { + showLines = true; + repaint(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } + + public void readFile(String filename) { + try { + scan = new Scanner(new File(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public Shape[] makeArr() { + readFile(filename); + amount = scan.nextInt(); + System.out.println(amount); + Shape shapes[] = new Shape[amount]; + + for (int i = 0; i < amount; i++) { + shapes[i] = new Shape(); + System.out.println("added"); + int aPoints = scan.nextInt(); + for (int j = 0; j < aPoints; j++) { + shapes[i].addPoint(scan.nextInt(), scan.nextInt()); + System.out.println("added2"); + System.out.println(shapes[i].getLength()); + } + } + startX = scan.nextInt(); + startY = scan.nextInt(); + return shapes; + } + + public int numberLines() { + int out = 0; + + for (Shape shape : shapes) { + out = out + shape.getLength(); + } + + return out; + } + + public Segment[] makeSegments() { + Segment[] segments = new Segment[numberLines() + 4]; + int tmpCounter = 0; + + for (Shape shape : shapes) { + for (int i = 0; i < shape.getLength(); i++) { + if (i < shape.getLength() - 1) { + segments[tmpCounter] = new Segment(new Vector(shape.getX(i), shape.getY(i)), + new Vector(shape.getX(i + 1), shape.getY(i + 1))); + } else { + segments[tmpCounter] = new Segment(new Vector(shape.getX(i), shape.getY(i)), + new Vector(shape.getX(0), shape.getY(0))); + } + tmpCounter++; + } + } + + segments[tmpCounter] = new Segment(new Vector(0, 0), new Vector(WIDTH, 0)); + tmpCounter++; + segments[tmpCounter] = new Segment(new Vector(WIDTH, 0), new Vector(WIDTH, HEIGHT)); + tmpCounter++; + segments[tmpCounter] = new Segment(new Vector(WIDTH, HEIGHT), new Vector(0, HEIGHT)); + tmpCounter++; + segments[tmpCounter] = new Segment(new Vector(0, HEIGHT), new Vector(0, 0)); + + return segments; + + } + + Segment[] createRays() { + + rays = new Segment[segments.length * 3]; + + int counter = 0; + + for (int s = 0; s < segments.length; s++) { + + Vector a = new Vector(startX, startY); + Vector b = segments[s].b; + Vector c = b.subtract(a).normalize(); + + Segment s1 = new Segment( + a, + b); + Segment s2 = new Segment( + a, + a.add(c.setDir(c.getAngle() + 0.00001f).normalize().scale(WIDTH))); + Segment s3 = new Segment( + a, + a.add(c.setDir(c.getAngle() - 0.00001f).normalize().scale(WIDTH))); + + rays[counter] = s1; + rays[counter + 1] = s2; + rays[counter + 2] = s3; + + counter += 3; + + } + return (sortRays()); + } + + Segment[] sortRays() { + + ArrayList list = new ArrayList(); + + for (int r = 0; r < rays.length; r++) { + list.add(rays[r]); + } + + list.sort(new Comparator() { + + @Override + public int compare(Segment e1, Segment e2) { + + Vector v1 = e1.b.subtract(e1.a); + Vector v2 = e2.b.subtract(e2.a); + + if (v1.getAngle() < v2.getAngle()) + return -1; + if (v1.getAngle() > v2.getAngle()) + return 1; + + return 0; + } + + }); + + for (int i = 0; i < list.size(); i++) { + + rays[i] = list.get(i); + + } + return rays; + } + + public void paint(Graphics g) { + + createRays(); + sortRays(); + + // TODO farbpalette und farben speichern + + // reset field + g.clearRect(0, 0, WIDTH, HEIGHT); + + // shapes + g.setColor(new Color(100, 255, 100)); + drawShapes(g); + + // borders + g.setColor(new Color(255, 255, 255)); + drawBorders(g); + + // TODO fix polygons + // make polygons + // g.setColor(new Color(100, 100, 200)); + // drawPolygons(g); + + // make lines + g.setColor(new Color(0, 0, 255)); + drawRays(g); + + // point + g.setColor(new Color(255, 100, 100)); + g.fillOval(startX - 10, startY - 10 + 100, 20, 20); + + } + + void drawBorders(Graphics g) { + for (Shape shape : shapes) { + p = new Polygon(); + for (int j = 0; j < shape.getLength(); j++) { + p.addPoint(shape.getX(j), shape.getY(j) + 100); + } + g.drawPolygon(p); + } + } + + void drawShapes(Graphics g) { + for (Shape shape : shapes) { + p = new Polygon(); + for (int j = 0; j < shape.getLength(); j++) { + p.addPoint(shape.getX(j), shape.getY(j) + 100); + } + g.fillPolygon(p); + } + } + + void drawRays(Graphics g) { + for (int r = 0; r < rays.length; r++) { + Segment ray = rays[r]; + + Vector closestIntersect = ray.b; + float distToIntersect = WIDTH; + + for (int i = 0; i < segments.length; i++) { + + Intersect inter = getIntersection(ray, segments[i]); + + if (inter != null) { + + float d = inter.distance; + + if (distToIntersect > d) { + distToIntersect = d; + closestIntersect = inter.intersect; + } + } + + } + + ray.b = closestIntersect; + } + + for (int r = 0; r < rays.length; r++) { + + Segment ray = rays[r]; + + g.drawLine((int) ray.a.x, (int) ray.a.y + 100, (int) ray.b.x, (int) ray.b.y + 100); + + } + } + + void drawPolygons(Graphics g) { + + for (int r = 0; r < rays.length; r++) { + + Segment ray1 = rays[r]; + Segment ray2; + + if (r == rays.length - 1) { + ray2 = rays[0]; + } else { + ray2 = rays[r + 1]; + } + + Polygon p; + int[] x_points = { (int) ray1.a.x, (int) ray1.b.x, (int) ray2.b.x }; + int[] y_points = { (int) ray1.a.y + 100, (int) ray1.b.y + 100, (int) ray2.b.y + 100 }; + + p = new Polygon(x_points, y_points, 3); + + g.fillPolygon(p); + + // g.setClip(p); + + } + } + + public void neuzeichnen() { + repaint(); + } + + public void anzeigenTxt() { + + } + + public void wait(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (Exception e) { + + } + } + + Intersect getIntersection(Segment s1, Segment s2) { + + Vector p = s1.a; + Vector q = s2.a; + Vector r = s1.b.subtract(s1.a); + Vector s = s2.b.subtract(s2.a); + + float t = (crossProduct(q, s) - crossProduct(p, s)) / crossProduct(r, s); + float u = (crossProduct(p, r) - crossProduct(q, r)) / crossProduct(s, r); + + if (t >= 0 && t <= 1 && u >= 0 && u <= 1) { + return new Intersect(new Vector(p.x + t * r.x, p.y + t * r.y), t); + } + return null; + } + + float crossProduct(Vector a, Vector b) { + return a.x * b.y - a.y * b.x; + } + + class Intersect { + Vector intersect; + float distance; + + Intersect(Vector i, float d) { + this.intersect = i; + this.distance = d; + } + + } + + class Segment { + + Vector a; + Vector b; + + Segment(Vector a, Vector b) { + this.a = a; + this.b = b; + } + + } + + class Vector { + float x; + float y; + + Vector(float x, float y) { + this.x = x; + this.y = y; + } + + Vector add(Vector v) { + return new Vector(x + v.x, y + v.y); + } + + Vector subtract(Vector v) { + return new Vector(x - v.x, y - v.y); + } + + float getM() { + return (float) (Math.sqrt(x * x + y * y)); + } + + Vector normalize() { + float m = getM(); + x = x / m; + y = y / m; + return this; + } + + Vector scale(float t) { + x *= t; + y *= t; + return this; + } + + Vector setDir(float angle) { + + float m = getM(); + return new Vector((float) (m * Math.cos(angle)), (float) (m * Math.sin(angle))); + + } + + float getAngle() { + return (float) Math.atan2(y, x); + } + + } + +}