Alles mal hochladen

master
Leon Schwenke 2025-12-20 15:41:02 +00:00
commit 6eae0efeed
153 changed files with 4448 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
public class Hello{
public static void main(String [] args){
System.out.println("Heeellloololololo");
}
}

Binary file not shown.

View File

@ -0,0 +1 @@
Main-Class: Hello.class

Binary file not shown.

View File

@ -0,0 +1,50 @@
package assignment009;
import assignment009.AudioPlayer;
public class MozartMain{
public static void main (String[] args){
WalzerGenerator schee = new WalzerGenerator();
int [] song = new int[32];
int [] song2 = new int[16];
int [] song3 = new int[16];
//Songs genrieren
schee.createWalz(0,song3);
schee.createTrio(0,song2);
for (int i = 0; i < song3.length; i ++){
System.out.print(song3[i] + " ");
}
System.out.println();
for (int i = 0; i < song2.length; i ++){
System.out.print(song2[i] + " ");
}
//Songs zusammenfügen
for (int i = 0; i < song.length; i++){
if (i<16){song[i] = song3[i];}
else{song[i] = song2[i-16];}
}
for (int i = 0; i < song.length; i++) {
if (i <= song.length/2) {
String fileMinuet = AudioPlayer.class.getClassLoader().getResource("res/M"+song[i]+".wav").toString();
AudioPlayer.play(fileMinuet);
}
else {
String fileTrio = AudioPlayer.class.getClassLoader().getResource("res/T"+song[i]+".wav").toString();
AudioPlayer.play(fileTrio);
}
}
}
}

View File

@ -0,0 +1,78 @@
package assignment009;
public class WalzerGenerator {
private int [][] minuet = new int [][] {
{96, 22, 141, 41, 105, 122, 11, 30, 70, 121, 26, 9, 112, 49, 109, 14},
{32, 6, 128, 63, 146, 46, 134, 81, 117, 39, 126, 56, 174, 18, 116, 83},
{69, 95, 158, 13, 153, 55, 110, 24, 66, 139, 15, 132, 73, 58, 145, 79},
{40, 17, 113, 85, 161, 2, 159, 100, 90, 176, 7, 34, 67, 160, 52, 170},
{148, 74, 163, 45, 80, 97, 36, 107, 25, 143, 64, 125, 76, 136, 1, 93},
{104, 157, 27, 167, 154, 68, 118, 91, 138, 71, 150, 29, 101, 162, 23, 151},
{152, 60, 171, 53, 99, 133, 21, 127, 16, 155, 57, 175, 43, 168, 89, 172},
{119, 84, 114, 50, 140, 86, 169, 94, 120, 88, 48, 166, 51, 115, 72, 111},
{98, 142, 42, 156, 75, 129, 62, 123, 65, 77, 19, 82, 137, 38, 149, 8},
{3, 87, 165, 61, 135, 47, 147, 33, 102, 4, 31, 164, 144, 59, 173, 78},
{54, 130, 10, 103, 28, 37, 106, 5, 35, 20, 108, 92, 12, 124, 44, 131}
};
private int [][] trio = new int [][] {
{72, 6, 59, 25, 81, 41, 89, 13, 36, 5, 46, 79, 30, 95, 19, 66},
{56, 82, 42, 74, 14, 7, 26, 71, 76, 20, 64, 84, 8, 35, 47, 88},
{75, 39, 54, 1, 65, 43, 15, 80, 9, 34, 93, 48, 69, 58, 90, 21},
{40, 73, 16, 68, 29, 55, 2, 61, 22, 67, 49, 77, 57, 87, 33, 10},
{83, 3, 28, 53, 37, 17, 44, 70, 63, 85, 32, 96, 12, 23, 50, 91},
{18, 45, 62, 38, 4, 27, 52, 94, 11, 92, 24, 86, 51, 60, 78, 31}
};
/**Würfeln mit math.rand zahl zwischen 1-6
* @param d1 = Würfel 1
* @param d2 = Würfel 2
* @param quant = Anzahl der würfel mit denen Gewürfelt wird
*
* Default ist mit zwei Würfeln
*/
public int rollDice(int quant){
int d1,d2;
d1 = (int) (Math.random() * 6);
d2 = (int) (Math.random() * 6);
if (quant == 1){return d1;}
else if (quant == 2){return d1 + d2;}
return d1 + d2;
}
public void createWalz(int count, int[] erg){
if (count >= 16){return;}
erg [count] = minuet[rollDice(2)][count];
createWalz(count + 1, erg);
}
public void createTrio(int count, int[] erg){
if (count >= 16){return;}
erg [count] = trio[rollDice(1)][count];
createTrio(count + 1, erg);
}
}

View File

@ -0,0 +1 @@
!mozart.jar

Binary file not shown.

Binary file not shown.

BIN
Stau/Fahrzeug.class 100644

Binary file not shown.

31
Stau/Fahrzeug.java 100644
View File

@ -0,0 +1,31 @@
public class Fahrzeug{
/**Instanzvariablen
*
*Hier werden Länge, Position und Fahrer festgelegt
*@param length type int, Länge in m, realistische Werte bevorzugt
*@param Fahrer type String, Randomsidefact für Fahrzeuginfo - der Fahrer
*@param position type int, Legt die Position in ArrayList fest.
*
*/
protected int length;
protected String fahrer;
protected int position;
protected String symbol;
//Konstruktor
Fahrzeug(int pos, int l, String f, String sym){
this.position = pos;
this.length = l;
this.fahrer = f;
this.symbol = sym;
}
Fahrzeug(int pos, String f){
this.position = pos;
this.fahrer = f;
}
}

View File

@ -0,0 +1,31 @@
public class Fahrzeug{
/**Instanzvariablen
*
*Hier werden Länge, Position und Fahrer festgelegt
*@param length type int, Länge in m, realistische Werte bevorzugt
*@param Fahrer type String, Randomsidefact für Fahrzeuginfo - der Fahrer
*@param position type int, Legt die Position in ArrayList fest.
*
*/
protected int length;
protected String fahrer;
protected int position;
protected String symbol;
//Konstruktor
Fahrzeug(int pos, int l, String f, String sym){
this.position = pos;
this.length = l;
this.fahrer = f;
this.symbol = sym;
}
Fahrzeug(int pos, String f){
this.position = pos;
this.fahrer = f;
}
}

BIN
Stau/LKW.class 100644

Binary file not shown.

7
Stau/LKW.java 100644
View File

@ -0,0 +1,7 @@
public class LKW extends Fahrzeug
{
LKW(int pos, String fahrer){
super(pos,7, fahrer, "[][===]");
}
}

7
Stau/LKW.java~ 100644
View File

@ -0,0 +1,7 @@
public class LKW extends Fahrzeug
{
LKW(int pos, String fahrer){
super(pos,6, fahrer, "[][==]");
}
}

BIN
Stau/MainStau.class 100644

Binary file not shown.

47
Stau/MainStau.java 100644
View File

@ -0,0 +1,47 @@
import java.util.ArrayList;
public class MainStau{
public static void main (String[] args){
ArrayList<Fahrzeug> stau = new ArrayList<>();
stau.add(new LKW(1, "Ronnie"));
stau.add(new Motorrad(9, "Knievel"));
stau.add(new LKW(13, "Jessi"));
stau.add(new LKW(21, "Jessi"));
stau.add(new LKW(29, "Jessi"));
stau.add(new PKW(37, "Tim"));
stau.add(new PKW(43, "Tim"));
stau.add(new Motorrad(49, "Leon"));
int len = 60;
char[] strasse = new char [len];
//Strasse bauen
for (int i = 0; i <strasse.length; i++){
strasse[i] = '_';
}
int staulaenge = 0;
//Fahrzeuge einfügen
for (Fahrzeug f : stau){
for (int i = 0; i < f.length; i++) {
int pos = f.position + i;
if (pos < strasse.length) {
strasse[pos] = f.symbol.charAt(i % f.symbol.length()); // erstes Zeichen
}
}
staulaenge += f.length;
}
System.out.print(strasse);
System.out.println("\nDer Stau ist " + staulaenge + "m lang! Fuckkk.");
}
}

View File

@ -0,0 +1,47 @@
import java.util.ArrayList;
public class MainStau{
public static void main (String[] args){
ArrayList<Fahrzeug> stau = new ArrayList<>();
stau.add(new LKW(1, "Ronnie"));
stau.add(new Motorrad(9, "Knievel"));
stau.add(new LKW(13, "Jessi"));
stau.add(new LKW(21, "Jessi"));
stau.add(new LKW(29, "Jessi"));
stau.add(new PKW(37, "Tim"));
stau.add(new PKW(43, "Tim"));
stau.add(new Motorrad(49, "Leon"));
int len = 60;
char[] strasse = new char [len];
//Strasse bauen
for (int i = 0; i <strasse.length; i++){
strasse[i] = '_';
}
int staulaenge = 0;
//Fahrzeuge einfügen
for (Fahrzeug f : stau){
for (int i = 0; i < f.length; i++) {
int pos = f.position + i;
if (pos < strasse.length) {
strasse[pos] = f.symbol.charAt(i % f.symbol.length()); // erstes Zeichen
}
}
staulaenge += f.length;
}
System.out.print(strasse);
System.out.println("\nDer Stau ist " + staulaenge + "m lang! Fuckkk.");
}
}

BIN
Stau/Motorrad.class 100644

Binary file not shown.

View File

@ -0,0 +1,9 @@
public class Motorrad extends Fahrzeug {
Motorrad(int pos, String fahrer){
super(pos,3, fahrer, "=-=");
}
}

View File

@ -0,0 +1,9 @@
public class Motorrad extends Fahrzeug {
Motorrad(int pos, String fahrer){
super(pos,2, fahrer, "=-=");
}
}

BIN
Stau/PKW.class 100644

Binary file not shown.

7
Stau/PKW.java 100644
View File

@ -0,0 +1,7 @@
public class PKW extends Fahrzeug {
PKW(int pos, String fahrer){
super(pos,5, fahrer, "[X-X]");
}
}

7
Stau/PKW.java~ 100644
View File

@ -0,0 +1,7 @@
public class PKW extends Fahrzeug {
PKW(int pos, String fahrer){
super(pos,4, fahrer, "[XX]");
}
}

Binary file not shown.

View File

@ -0,0 +1,23 @@
public class Adress{
//Instanzvariablen
private String name;
private int number;
//Konstruktor
Adress(String name, int num){
this.name = name;
this.number = num;
}
//Methoden
public String getName() {return this.name;}
public int getNumber() {return this.number;}
public void setName(String newname) {this.name = newname;}
public void setNumber(int newnumber) {this.number = newnumber;}
}

Binary file not shown.

View File

@ -0,0 +1,32 @@
import java.util.Random;
public class Adventskalender{
public static void main (String[] args){
int i; //Schleife
String[] a = new String [] {"Eier", "Zigaretten", "Bier", "Bubatz", "Messer", "Gehstock", "LKW Führerschein", "Nokia N95",
"Socken", "Mütze", "Sonnenbrille", "Schoki", "Mehr Bier", "Kaugummi", "Anime", "Lebensabschnittspartner", "Ohrringe",
"Cobratatoo", "Cousine 2ten Grades", "Leere Batterie", "Schildkröte", "Jogger", "Pennerhandschuhe", "Zippo"};
int [] tuer = new int [] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
System.out.println("HalloooO");
Random rand = new Random();
for (i = 0; i < tuer.length; i++){
int index = rand.nextInt(tuer.length);
System.out.println("Du öffnest Tür " + tuer[i] + " und bekommst: " + a[i]);
}
System.out.println("Ciao");
}
}

28
TestProgs/Animal 100644
View File

@ -0,0 +1,28 @@
class Animal{
//Instanzvariabeln
privat int size;
privat int age;
privat String name;
privat String breed;
privat String haut;
//Konstruktor
class Animal (int size, String name, String breed, String haut);
class Animal (String name, String breed);
//Methoden
public void eat{
System.out.println("Munch munch");
}
pubic void getName{
System.out.println(this.name);
}
public String getInfo{
return "This is " + name + " a " + breed + " which is " + age + " Years old and has a height of " + size + ". Its skin is " + haut + ".";
}
}

Binary file not shown.

View File

@ -0,0 +1,38 @@
public class Animal{
//Instanzvariabeln
protected int size;
protected int age;
protected String name;
protected String breed;
protected String haut;
/*Konstruktor
Animal (int a, int s, String n, String b, String h){
age = a;
size = s;
name = n;
breed = b;
haut = h;
}
Animal (String n, String b){
this.name = n;
this.breed = b;
}*/
//Methoden
public void eat(){
System.out.println("Munch munch");
}
public String getName(){
return this.name;
}
public String getInfo(){
return "This is " + name + " a " + breed + " which is " + age + " Years old and has a height of " + size + ". Its skin is " + haut + ".";
}
}

BIN
TestProgs/Arr.class 100644

Binary file not shown.

25
TestProgs/Arr.java 100644
View File

@ -0,0 +1,25 @@
public class Arr{
public static void main (String[] args){
int [][][] a = new int [3][4][5];
for(int x = 0; x < a.length; x++){
for(int y = 0; y < a[x].length; y++){
System.out.println();
for (int z = 0; z < a[x][y].length; z++){
a[x][y][z] = 10*y+z-2*x;
System.out.print(a[x][y][z] + " ");
}
}
}
}
}

Binary file not shown.

View File

@ -0,0 +1,31 @@
import java.lang.Math;
public class Arrayzz{
public static void main (String[] args){
int i;
int b = 0;
int [] a;
a = new int [100];
for (i = 0; i < a.length; i ++){
a[i] = (int)(Math.random()*100);
System.out.print(a[i] + " ");
b += a[i];
}
System.out.println("\nIch bin ein Array das " + a.length + " lang ist.");
b = b/a.length;
System.out.println("Der Durchschnitt der Randomwerte ist : " + b);
}
}

9
TestProgs/Bear 100644
View File

@ -0,0 +1,9 @@
class Bear extends Animal{
public void eat{
System.out.println("NomNomNom");
}
}

Binary file not shown.

View File

@ -0,0 +1,24 @@
public class Bear extends Animal{
//Konstruktor
Bear (int a, int s, String n, String b, String h){
age = a;
size = s;
name = n;
breed = b;
haut = h;
}
Bear (String n, String b){
this.name = n;
this.breed = b;
}
public void eat(){
System.out.println("NomNomNom");
}
}

Binary file not shown.

View File

@ -0,0 +1,31 @@
public class BinomialCoefficient{
public static void main (String[] args){
int n = Integer.parseInt(args[0]);
int z = 1; // Zeilen Schleife
int s = 1; // Spalten Schleife
//Ausgabe
for (z = 1; z < n; z++){
long a = 1; // Variable zur Berechnung
for (s = 1; s <= z ; s++){
System.out.print(a + " ");
if (s < z){ //Nicht durch 0 teilen
a = a * (z - s)/(s + 1);
}
}
System.out.println(); //Neue Zeile
}
}
}

Binary file not shown.

View File

@ -0,0 +1,47 @@
public class BitShift{
public static void main(String[] args){
int r;
int rr;
int l;
//Eingabe
int n = Integer.parseInt(args[0]);
//Berechnung
// >> Schiebt von links nach rechts, bei der letzten 1. Vorzeichenbit wird beachtet
r = n >> 1;
System.out.println("Arithmetische Bit-Verschieibung nach rechts ( / 2): " + r);
// << schiebt von recht nach links Nullen auf, Vorzeichenbit wird beachtet
l = n << 1;
System.out.println("Arithmetische Bit-Verschieibung nach links ( * 2): " + l);
// >>> schiebt ab Stelle 2^32 Nullen auf, Vorzeichenbits werden nicht beachtet
rr = n >>> 1;
System.out.println("Logische Bit-Verschieibung nach rechts: " + rr);
}
}
/*
3. Bei negativen Zahlen wird das Ergebnis bei der logischen Bitverschiebung sehr groß, da durch die vorherige Invertierung alle vorausgehender 0 zu 1 wurden.
Bsp.: -8
Gibt man jedoch eine beliebige postiive Zahl ein, sind die Ergbnisse gleich.
Bsp.: 6
*/

View File

@ -0,0 +1,4 @@
public class Breeder {
public static void main(String[] args) {
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,58 @@
public class Breeder {
public static void main(String[] args) {
//static int count;
//So kann man privat umgehen
Dog samy = new Dog(2, 4, "Samy", "Mischling");
Dog anouk = new Dog(3, 2, "Anouk", "Mischling");
Dog floki = new Dog(2, 7, "Floki", "Weißer Schäferhund");
Dog copy = new Dog(floki);
Shoebill joe = new Shoebill("Joe", 4, 100, 2);
System.out.println(joe.getName());
joe.setName("Jonathan");
System.out.println(joe.getName());
System.out.println("Anzahl der Hunde: " + Dog.count);
System.out.println(Dog.getCount());
/*
samy.size = 4;
samy.name = "Samy";
samy.breed = "Mischling";
anouk.size = 3;
anouk.name = "Anouk";
anouk.breed = "Bitch";
floki.size = 7;
floki.name = "Floki";
floki.breed = "Weißer Schäferhund";
*/
System.out.println(samy.printInfo());
samy.bark(2);
System.out.println(anouk.printInfo());
anouk.bark(3);
System.out.println(floki.printInfo());
floki.bark(4);
System.out.println(floki.wagingTail());
}
}

Binary file not shown.

View File

@ -0,0 +1,50 @@
public class Chairs{
public static void main (String[] args){
char a = 'a';
char b = 'b';
char c = 'c';
char d = 'd';
char e = 'e';
char t; //Tauschvariable
//Ausgabe
System.out.println (a + " sitzt auf Stuhl A, " + b + " sitzt auf Stuhl B, " + c +
" sitzt auf Stuhl C, " + d + " sitzt auf Stuhl D, " + e + " sitzt auf Stuhl E.");
//Tauschalgorithmus
t = e;
e = d;
d = c;
c = b;
b = a;
a = t;
System.out.println (a + " sitzt auf Stuhl A, " + b + " sitzt auf Stuhl B, " + c +
" sitzt auf Stuhl C, " + d + " sitzt auf Stuhl D, " + e + " sitzt auf Stuhl E.");
while (a != 'a'){
t = e;
e = d;
d = c;
c = b;
b = a;
a = t;
System.out.println (a + " sitzt auf Stuhl A, " + b + " sitzt auf Stuhl B, " + c +
" sitzt auf Stuhl C, " + d + " sitzt auf Stuhl D, " + e + " sitzt auf Stuhl E.");
}
}
}

11
TestProgs/Croc 100644
View File

@ -0,0 +1,11 @@
class Croco extends Animal{
//Methoden
public void eat(){
System.out.println("Happ Happ");
}
}

11
TestProgs/Croco 100644
View File

@ -0,0 +1,11 @@
class Croco extends Animal{
//Methoden
public void eat(){
System.out.println("Happ Happ");
}
}

Binary file not shown.

View File

@ -0,0 +1,25 @@
public class Croco extends Animal{
//Konstruktor
Croco (int a, int s, String n, String b, String h){
age = a;
size = s;
name = n;
breed = b;
haut = h;
}
Croco (String n, String b){
this.name = n;
this.breed = b;
}
//Methoden
public void eat(){
System.out.println("Happ Happ");
}
}

Binary file not shown.

View File

@ -0,0 +1,154 @@
public class DiamondDeluxe{
private int n,i,j,k;
private boolean b;
//Konstuktor
DiamondDeluxe(int n){
this.n = n;
this.b = false; //Übergabeparameter
}
public DiamondDeluxe cut(){
//Wenn Größe = 1, passiert nüscht
if (n == 1){
this.n = n;
}
//Verkleinern um 2
else {
this.n = this.n - 2;
}
return this;
}
public DiamondDeluxe setBorder(boolean b){
//b in this.b speichern für mit oder ohne Rand
this.b = b;
return this;
}
public DiamondDeluxe print(){
if (b){
//ooooooooooooooooooooo
for (i = 0; i < n; i++){
System.out.print("o");
}
}
//______________________________________Obere Hälfte Diamant________________________________________
int z = 1; // Zähler für "*"
int g = (n-3)/2; // Obere Hälfte + Mitte
//bis n/2 weil es nur obere Hälfte
for (j = 0; j < n/2; j++ ){
if (b){
//Erste stelle o
System.out.print("\no");
}
else{System.out.println();}
//Punktausgabe
for (k = 0; k < g; k++){
System.out.print(".");
}
//Ausgabe Stern
for (i = 0; i < z; i ++){
System.out.print("*");
}
//Zähler +2 wil immer 2 Sternchen mehr
z = z+2;
for (k = 0; k < g; k++){
System.out.print(".");
}
//letztes o
if (b){
System.out.print("o");
}
g--;
}
//______________________________________Untere Hälfte Diamant________________________________________
z = 1; //Zähler für "."
g = n-4; //-4 wegen o am Rand und Mitte ist schon
//bis n/2-1 weil die midde is oben schon
for (j = 0; j < n/2-1; j++ ){
if (b){
System.out.print("\no");
}
else{System.out.println();}
for (i = 0; i < z; i ++){
System.out.print(".");
}
for (k = 0; k < g; k++){
System.out.print("*");
}
g = g-2;
for (i = 0; i < z; i ++){
System.out.print(".");
}
if (b){
System.out.print("o");
}
z++;
}
//Letzte Reihe ooooooooo
if (b){
System.out.println();
for (i = 0; i < n; i++){
System.out.print("o");
}
}
System.out.println();
//______________________________________Quasten mit/ohne Rand_________________________________________
//Mit (+1)
if (b){
int x = (n+1)/2;
for (i = 0; i < x; i++){
System.out.print("| ");
}
System.out.println();
for (i = 0; i < x; i++){
System.out.print("X ");
}
}
//ohne (-1)
else{
int x = (n-1)/2;
for (i = 0; i < x; i++){
System.out.print("| ");
}
System.out.println();
for (i = 0; i < x; i++){
System.out.print("X ");
}
}
return new DiamondDeluxe(n);
}
}

Binary file not shown.

View File

@ -0,0 +1,24 @@
public class DiamondDeluxeMain {
public static void main(String[ ] args) {
new DiamondDeluxe(15)
.cut()
.cut()
.setBorder(true)
.print ();
new DiamondDeluxe(41)
.cut()
.cut()
.setBorder(true)
.print ();
new DiamondDeluxe(5)
.cut()
.cut()
.setBorder(true)
.print ();
}
}

BIN
TestProgs/Dog.class 100644

Binary file not shown.

92
TestProgs/Dog.java 100644
View File

@ -0,0 +1,92 @@
public class Dog{
//Instanzvariabeln
private int size;
private int age;
private String name;
private String breed;
private boolean necklace = false;
static int count = 0;
//Konstruktor
Dog(int a, int s, String n, String b){
age = a;
size = s;
name = n;
breed = b;
count++;
}
Dog(that.Dog){
;
}
//Methode
public static int getCount(){
System.out.println("Erzeugte Hunde: ");
return Dog.count;
}
public String printInfo() {
return name + " ist von der Rasse: " + breed + " hat eine Größe von: " + size+ " und ist " + age + " Jahre alt.";
}
public void bark(int numOfBarks){
while (numOfBarks > 0){
if (size < 4 ){
System.out.println ("Yip! Yip!");
}
else if (size > 6 ){
System.out.println ("Woof! Woof!");
}
else {
System.out.println ("Ruff! Ruff!");
}
numOfBarks--;
}
//NumOfBarks = NumOfBarks - 1;
}
public String wagingTail(){
return name + "s Schwanz wedelt";
}
public String getBreed(){
return breed;
}
public Dog getClass(){
return Dog;
}
public boolean equals (Obejct x){
if(x == null)
{return false;}
if(getClass()!= x.getClass())
{return false;}
if (getBreed() !=x.getBreed());
{return false;}
return true;
}
}

View File

@ -0,0 +1,76 @@
public class Hanoi {
//Instanzvariablen
private final int size = 3;
private int [][] field;
//Konstruktor
Hanoi(){
field = new int [size][size];
}
//Methoden
//@param int choice, 1-size valid
//output: Hanoi
private Hanoi left(int choice){
if (!isDirectionVaild(true, choice)){
System.out.println("Geht nich");
}
}
//ValidTower - ist auf dem Turm eine scheibe
private boolean isTowerValid(int check){
if(!isChoiceValid(check)){return false;}
for (int i = 0; i <= size; i++){
if (field[check][i] != 0){
return true;
}
}
return false;
}
private boolean isChoiceValid(int choice){
return choice > 0 && choice <= size;
}
private int highestSlice (int tower){
int res = 0;
for (int i = 0; i < size; i++){
if(field[tower][i] != 0){
res = field[tower][i];
}
}
return res;
}
//
private boolean isDirectionVaild(boolean direct, int tower){
if(!isTowerValid(tower)){return false;}
int varli = tower == 0 ? 2 : tower-1;
int varre = tower == 2 ? 0 : tower+1;
//direct = true = links
if (direct){
if (highestSlice(tower) < highestSlice(varli)){return true;}
}
if (!direct){
if (highestSlice(tower) < highestSlice(varre)){return true;}
}
return false;
}
}

View File

@ -0,0 +1,8 @@
public enum HotelAdministrator{
public static void main (String[] args){
}
}

Binary file not shown.

View File

@ -0,0 +1,9 @@
public class HotelAdministrator{
public static void main (String[] args){
System.out.println(HotelMeal.Breakfast);
}
}

Binary file not shown.

View File

@ -0,0 +1,54 @@
public enum HotelMeal{
Breakfast(7,30), Lunch(12,15), Dinner(19,45);
private int hh, mm;
//Konstruktor
HotelMeal (int a, int b){
this.hh = a;
this.mm = b;
}
public int foodtime(){
return 0;
}
//Methoden
public int getHour(){
return this.hh;
}
public int getMinute(){
return this.mm;
}
public String getTime(){
return this.hh + ":" + this.mm;
}
/*
public String Meal(HotMeal a){
if (time = 7:30){
System.out.println("Breakfast");
}
else if (time = 12:15){
System.out.println("Lunch");
}
else if (time = 19:45){
System.out.println("Dinner");
}
else {System.out.println("No Food!");}
}
*/
}

Binary file not shown.

View File

@ -0,0 +1,38 @@
public class Human{
//Instanzvariablen
private Name Name1;
private Adress Adress1;
//Konstruktor
Human (Name KonsName, Adress Adress){
this.Name1 = KonsName;
this.Adress1 = Adress;
}
//Copy-Konstruktor (Deep) erschafft neues gleiches Objekt
Human (Human that){
Adress1 = new Adress(that.Adress1.getName(), that.Adress1.getNumber());
Name1 = new Name(that.Name1.getFirst(), that.Name1.getLast());
}
/*
//Shallow Copy hat gleiche Referenz
Human (Human b){
this.Adress1 = b.Adress1;
this.Name1 = b.Name1;
}
*/
public String getName(){return Name1.getFirst() + Name1.getLast();}
public String getAdress(){return Adress1.getName() + Adress1.getNumber();}
public void greet(){System.out.println("Hallo, mein Name ist " + this.Name1.getFirst());}
public void setFirst(String first){this.Name1.setFirst(first);}
public void setLast(String last){this.Name1.setLast(last);}
}

Binary file not shown.

View File

@ -0,0 +1,24 @@
public class HumanMain{
public static void main(String[] args){
Name NameA = new Name ("Alex", "Hoden");
Adress AdressA = new Adress ("Kaiserschmarn", 2);
Human Alex = new Human (NameA, AdressA);
Human Axel = new Human(Alex);
Alex.greet();
Axel.greet();
Axel.setFirst("Axel");
Axel.greet();
Alex.greet();
}
}

View File

@ -0,0 +1,8 @@
int num = -5;
if (!(num > 0)) {
if (!(num == 0)) {
System.out.println("Negative number");
}
}

Binary file not shown.

View File

@ -0,0 +1,14 @@
//My Program 1
public class MyProgram1{
public static void main(String[] args){
//jsgkjsdgf
/*gsdfgs
df
dfgdfgd
fgdfg
sdfgsdg
d*/
}
}

Binary file not shown.

View File

@ -0,0 +1,22 @@
public class Name{
//Instansvariablen
private String first;
private String last;
//Konstruktor
Name (String first, String last){
this.first = first;
this.last = last;
}
//Methoden
public String getFirst(){return this.first;}
public String getLast(){return this.last;}
public void setFirst(String first){this.first = first;}
public void setLast(String last){this.last = last;}
}

Binary file not shown.

View File

@ -0,0 +1,54 @@
import java.lang.Math;
public class PerfectNumber{
public static void main (String[] args){
long a = 1; //Ausgabe
long zw1 = 0; //Zwischenrechnung
long zw2 = 0; //Zwischenrechnung
int i = 2; //Schleife
int j = 1; //Schleife
System.out.println("5 Perfect Numeros.");
while (i < 14){
if (i == 2 || i == 3 || i == 5 || i == 7 || i == 13 ){
System.out.println();
zw1 = (long) Math.pow(2,(i-1));
zw2 = (long) Math.pow(2,i);
a = zw1 * (zw2-1);
System.out.print( a + " = ");
for (j = 1; j < a/2+1; j++){
if (a % j == 0){
if(j == a/2){
System.out.print(j);
}
else {
System.out.print(j + " + ");
}
}
}
}
i ++;
}
}
}

Binary file not shown.

View File

@ -0,0 +1,64 @@
/**
* Class File Coins of Assignment 3
*/
public class Poins {
public static void main(String[] args) {
//Einlesen des Wertes von der Konsole
System.out.println("Gib Euros ein:");
double euro = Double.parseDouble( args[0] );
System.out.println("Gib Cents ein:");
double cent = Double.parseDouble( args[0] );
euro = euro + cent;
int euro2 = 0;
int euro1 = 0;
int cent50 = 0;
int cent20 = 0;
int cent10 = 0;
int cent5 = 0;
int cent2 = 0;
int cent1 = 0;
euro = euro * 100;
euro2 = (int)euro/200;
euro = euro - euro2*200;
euro1 = (int)euro/100;
euro = euro - euro1*100;
cent50 = (int)euro /50;
euro = euro - cent50*50;
cent20 = (int)euro /20;
euro = euro - (cent20*20);
cent10 = (int)euro/10;
euro = euro - cent10*10;
cent5 = (int)euro /5;
euro = euro - cent5*5;
cent2 = (int)euro / 2;
euro = euro - cent2*2;
cent1 = (int)euro;
//euro = euro -(double)cent1*0.01;
//Ausgabe
System.out.println(euro2 + " x 2 Euro");
System.out.println(euro1 + " x 1 Euro");
System.out.println(cent50 + " x 50 Cent");
System.out.println(cent20 + " x 20 Cent");
System.out.println(cent10 + " x 10 Cent");
System.out.println(cent5 + " x 5 Cent");
System.out.println(cent2 + " x 2 Cent");
System.out.println(cent1 + " x 1 Cent");
}
}

View File

@ -0,0 +1,25 @@
public static class Point{
//Instanzvariablen
double x;
double y;
//Konstruktor
Point(double x, double y){
double getX();
double getY();
}
//Methoden
double getX(){
return x;
}
double getY(){
return y;
}
}

View File

@ -0,0 +1,14 @@
public class Product{
double a,b;
Prodcut(double a, double b){
this.a = a;
this.b = b;
}
public double calc(){
return this.a * this.b;
}
}

19
TestProgs/Quiz 100644
View File

@ -0,0 +1,19 @@
import java.util.Scanner;
public class Quiz {
public static void main(String[] args){
System.out.println("____________________\n Quiz des Wissens Longa\n_____________________");
System.out.println("Frage 1:\nWas ist deine Liebslingsfarbe?\n");
int a = sc.nextInt();
switch (a){
case 2 -> System.out.println("Juhu Richtig");
default -> System.out.println("Falsch alla");
}
}
}

Binary file not shown.

View File

@ -0,0 +1,29 @@
import java.util.Scanner;
public class Quiz {
public static void main(String[] args){
System.out.println("____________________\n Quiz des Wissens Longa\n_____________________");
System.out.println("Frage 1:\nWelcher Kurs ist der beschde?\n");
System.out.println("1. IEB\n2. CSB\n3. UIB \n4. Keiner!!11!");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
switch (a){
case 2 -> System.out.println("Juhu Richtig\n");
default -> System.out.println("Falsch alla\n");
}
System.out.println("Frage 2:\nWie findsch den Todorov?\n");
System.out.println("1. Ziemlich Cute \n2. Nur Cute wenn er draußen ist\n3. Garnicht gut\n4. Ganz ok :)");
int b = sc.nextInt();
if (b == 1 || b == 2 || b == 3 || b == 4)
{
System.out.println("Fühl ich");
}
}
}

Binary file not shown.

View File

@ -0,0 +1,169 @@
public class Rational{
//Instanzvariablen
private int num;
private int denom;
private int newnum;
private int newdenom;
private int i, j; // Schleife
private double erg;
//Konstruktoren
public Rational(int n, int d){
this.num = n;
this.denom = d;
}
public Rational(int n){
this.num = n;
this.denom = 1;
}
//Methoden
public String reciprocal(){
return denom + "/" + num;
}
public String ausgabe(){
erg = (double)num/(double)denom;
return num + "/" + denom + " = " +erg;
}
//Zähler setzen
void setNum(int num)
{
this.num = num;
}
// Nenner setzen
void setDenom(int denom){
this.denom = denom;
}
//Zählerausgabe
public int getNum(){
return num;
}
//Nennerausgabe
public int getDenom(){
return denom;
}
//Kürzen
public Rational cut(){
newnum = this.num;
newdenom = this.denom;
if (this.denom < this.num){
for (i = this.denom; i > 1; i--){
if(this.denom % i == 0 && this.num % i == 0 ){
newdenom = this.denom / i;
newnum = this.num / i;
i = 2;
}
}
}
else if (this.denom > this.num){
for (i = this.num; i > 1; i--){
if(this.denom % i == 0 && this.num % i == 0 ){
newdenom = this.denom / i;
newnum = this.num / i;
i = 2;
}
}
}
return new Rational (newnum, newdenom);
}
//Addition
public Rational add(Rational onner){
if (this.denom == onner.denom){
newnum = this.num+onner.num;
newdenom = this.denom;
}
else{
newnum = this.num * onner.denom + onner.num * this.denom;
newdenom = this.denom * onner.denom;
}
Rational Wat = new Rational (newnum, newdenom);
return Wat.cut();
}
//Subtraktion
public Rational sub(Rational onner){
if (this.denom == onner.denom){
newnum = this.num-onner.num;
newdenom = this.denom;
}
else{
newnum = this.num * onner.denom - onner.num * this.denom;
newdenom = this.denom * onner.denom;
}
Rational Wat = new Rational (newnum, newdenom);
return Wat.cut();
}
//Multiplikation zweier Klassen
public Rational mult(Rational onner){
newnum = this.num * onner.getNum();
newdenom = this.denom * onner.getDenom();
Rational Wat = new Rational (newnum, newdenom);
return Wat.cut();
}
//Division zweier Brüche
public Rational div(Rational onner){
newnum = this.num * onner.denom;
newdenom = this.denom * onner.num;
Rational Wat = new Rational (newnum, newdenom);
return Wat.cut();
}
@Override
public String toString(){
return num + "/" + denom;
}
}

View File

@ -0,0 +1,15 @@
public class Rational{
public static void main (String args[]){
}
}

Binary file not shown.

View File

@ -0,0 +1,27 @@
public class RationalsMain{
public static void main (String [] args){
//Neue Klasse
Rational vierfuenftel = new Rational(4,5);
Rational sechssiebtel = new Rational(6,7);
Rational zehnfuenftel = new Rational(10,5);
Rational wtf = new Rational(24,6);
//Methodenaufruf
System.out.println("Wert des Zählers: "+ vierfuenftel.getNum());
System.out.println("Wert des Nenners: "+ vierfuenftel.getDenom());
System.out.println("Bruch als String: "+ vierfuenftel.ausgabe());
System.out.println("Addition mit 6/7: "+ vierfuenftel.add(sechssiebtel));
System.out.println("Subtraktion mit 6/7: "+ vierfuenftel.sub(sechssiebtel));
System.out.println("Multiplikation mit 6/7: "+ vierfuenftel.mult(sechssiebtel));
System.out.println("Division mit 6/7: "+ vierfuenftel.div(sechssiebtel));
System.out.println("Kürzen von 24/6: "+ wtf.cut() + "\n(Es wird nach jeder Rechnung gekürzt)");
System.out.println("Kehrwert " + vierfuenftel.reciprocal());
}
}

Binary file not shown.

View File

@ -0,0 +1,31 @@
public class Rekursion{
//eins bis n iterativ addieren
//k = (n*(n+1))/2
static int k, n;
//Gauss
private static int rekursiv(int n){
if (n == 1)
{return 1;}
return rekursiv (n-1) + n;
}
public static int iterativ(k){
}
public static void main (String [] args){
System.out.println(rekursiv(5));
}}

Binary file not shown.

View File

@ -0,0 +1,24 @@
public class SatelliteTime{
public static void main(String[] args){
int n = Integer.parseInt(args[0]);
//Sekunden in Tage, Stunden, Minuten, Sekunden
int d = 0;
int h = 0;
int m = 0;
int s = 0;
//Berechnung
d = n/86400;
h = (n - (d*86400))/3600;
m = (n - (d*86400) - (h*3600)) / 60;
s = n % ((d*86400) + (h*3600) + (m*60));
//Ausgabe
System.out.println (d + " Tage " + h + "Stunden " + m + " Minuten " + s + " Sekunden " );
}
}

Binary file not shown.

View File

@ -0,0 +1,53 @@
public class Shoebill{
//Instanzvariablen
private int age;
private int size;
private String name;
private int numOfLegs;
Shoebill(String n, int a, int s, int num){
this.age = a;
this.name = n;
this.size = s;
this.numOfLegs = num;
}
void setName(String n){
this.name = n;
}
void setSize (int s){
this.size = s;
}
void setAge(int a){
this.age = a;
}
void setnumOfLegs (int num){
this.numOfLegs = num;
}
String getName(){
return name;
}
int getAge(){
return age;
}
int getSize(){
return size;
}
int getNumOfLegs(){
return numOfLegs;
}
}

Binary file not shown.

View File

@ -0,0 +1,26 @@
public class Stringvergleich{
public static void main (String[] args){
String a = "Leck mich doch am Zueckerli";
String b = " Bananen sind braun";
String c = "Leck mich doch am Zueckerli";
String d = a + b;
String e = new String("Bananen sind braun");
String f = new String("Bananen sind braun");
/*
System.out.println(a.equals(b));
System.out.println(a.equals(c));*/
System.out.println(f.equals(e));
System.out.println(f == e);
/*
System.out.println(a == c);
System.out.println(a == b);
System.out.println(d == c);
*/
}
}

Binary file not shown.

View File

@ -0,0 +1,82 @@
public class Student{
//Instanzvariablen
private String vorname;
private String nachname;
private String wohnort;
private String studiengang;
private int alter, matrnr;
//Konstruktor
public Student(String vn, String nn, String w, String s, int a, int m){
this.vorname = vn;
this.nachname = nn;
this.wohnort = w;
this.studiengang = s;
this.alter = a;
this.matrnr = m;
}
//Methoden
//Setter
public String setVorname(String n){
this.vorname = n;
return n;
}
public String setNachname(String n){
this.nachname = n;
return n;
}
public int setAge(int a){
this.alter = a;
return 0;
}
public String setWohnort(String w){
this.wohnort = w;
return w;
}
public String setStudiengang(String s){
this.studiengang = s;
return s;
}
public int setMatrnr(int m){
this.matrnr = m;
return 0;
}
//Getter
public String getVorname(){
return this.vorname;
}
public String getNachname(){
return this.nachname;
}
public int getAge(){
return this.alter;
}
public String getWohnort(){
return this.wohnort;
}
public String getStudiengang(){
return this.studiengang;
}
public int getMatrnr(){
return this.matrnr;
}
}

Some files were not shown because too many files have changed in this diff Show More