help me lord

This commit is contained in:
Sage The DM 2024-11-23 21:34:00 +01:00
parent fb196693e4
commit db6b2a2a6e
42 changed files with 342 additions and 0 deletions

View file

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View file

@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,10 @@
// Hauptprogramm App
public class App {
public static void main(String[] args) {
Auto auto = new Auto("Ferrari");
Boot boot = new Boot("Titanic");
auto.bewegen();
boot.bewegen();
}
}

Binary file not shown.

View file

@ -0,0 +1,12 @@
// Klasse Auto
public class Auto extends Fahrzeug {
public Auto(String name) {
super(name);
}
@Override
public void bewegen() {
System.out.println("Das Auto " + getName() + " fährt auf der Strasse.");
}
}

Binary file not shown.

View file

@ -0,0 +1,11 @@
// Klasse Boot
public class Boot extends Fahrzeug {
public Boot(String name) {
super(name);
}
@Override
public void bewegen() {
System.out.println("Das Boot " + getName() + " fährt auf dem Wasser.");
}
}

Binary file not shown.

View file

@ -0,0 +1,14 @@
// Basisklasse Fahrzeug
public abstract class Fahrzeug {
private String name;
public Fahrzeug(String name) {
this.name = name;
}
public String getName() {
return name;
}
public abstract void bewegen();
}

View file

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View file

@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,24 @@
public class App {
public static void main(String[] args) throws Exception {
Kreis myKreis = new Kreis("blau", 10, 5, 1);
Rechteck myRechteck = new Rechteck("gelb", 0, -12, 2, 5);
System.out.println("Werte vor der modifizierung");
zeichne(myKreis, myRechteck);
System.out.println("modifikationen");
myKreis.position.bewegen(12, -11);
myRechteck.position.bewegen(33, 12);
myKreis.aendereRadius(3);
myRechteck.aendereGroesse(23, 12);
System.out.println("Werte nach der Veränderung");
zeichne(myKreis, myRechteck);
}
private static void zeichne(Kreis myKreis, Rechteck myRechteck) {
myKreis.zeichnen();
myRechteck.zeichnen();
}
}

View file

@ -0,0 +1,17 @@
public abstract class Form {
protected String farbe;
protected Position position;
public Form(String farbe, int x, int y) {
this.farbe = farbe;
Position tempPosition = new Position(x, y);
this.position = tempPosition;
}
public Position getPosition() {
return position;
}
protected abstract void zeichnen();
}

View file

@ -0,0 +1,18 @@
public class Kreis extends Form {
private int radius;
public Kreis(String farbe, int x, int y, int radius) {
super(farbe, x, y);
this.radius = radius;
}
public void aendereRadius(int myInt) {
this.radius += myInt;
}
@Override
public void zeichnen() {
System.out.println("Zeichne Kreis an der Position (" + getPosition().getX() + ", " + getPosition().getY()
+ ") mit dem radius " + radius);
}
}

View file

@ -0,0 +1,30 @@
public class Position {
int x;
int y;
Position(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public void bewegen(int x, int y) {
setX(x);
setY(y);
}
}

View file

@ -0,0 +1,21 @@
public class Rechteck extends Form {
private int hoehe;
private int breite;
public Rechteck(String farbe, int x, int y, int hoehe, int breite) {
super(farbe, x, y);
this.hoehe = hoehe;
this.breite = breite;
}
public void aendereGroesse(int hoehe, int breite) {
this.hoehe = hoehe;
this.breite = breite;
}
@Override
public void zeichnen() {
System.out.println("Zeichne ein Rechteck an der Position (" + getPosition().getX() + ", " + getPosition().getY()
+ ") mit der Breite " + breite + " und der Höhe " + hoehe);
}
}

View file

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View file

@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,16 @@
public class App {
public static void main(String[] args) throws Exception {
// Aufgabe 1
System.out.println("Aufgabe 1: \n");
Konto konto1 = new Konto("0000000001", 1000);
System.out.println(konto1.toString());
konto1.einzahlen(500);
konto1.abheben(750);
System.out.println("\nDaten nach transaktionen: ");
System.out.println(konto1.toString());
// Aufgabe 2
System.out.println("Aufgabe 2");
}
}

Binary file not shown.

View file

@ -0,0 +1,40 @@
public class Konto {
private String kontonummer;
private double kontostand;
public Konto(String kontonummer, int kontostand) {
if (kontonummer.length() == 10) {
this.kontonummer = kontonummer;
this.kontostand = kontostand;
} else
System.out.println("Es ist fehler beim erstellen des Konto aufgetreten");
}
public String getKontonummer() {
return kontonummer;
}
public double getKontostand() {
return kontostand;
}
public void abheben(double betrag) {
if (kontostand >= 0) {
this.kontostand -= betrag;
} else
System.out.println("Fehlermeldung #1225");
}
public void einzahlen(double betrag) {
if (kontostand >= 0) {
this.kontostand += betrag;
} else
System.out.println("Fehlermeldung #5221");
}
@Override
public String toString() {
return "Konto [Kontonummer=" + kontonummer + ", Kontostand=" + kontostand + "CHF]";
}
}

View file

@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}

View file

@ -0,0 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,14 @@
public class App {
public static void main(String[] args) throws Exception {
SimpleCalendar simpleCalendar = new SimpleCalendar();
// Aktuelles Datum und Uhrzeit formatieren und ausgeben
System.out.println("Aktuelles Datum und Uhrzeit:");
System.out.println(simpleCalendar.getFormattedDate());
// Zeit manipulieren
simpleCalendar.add(SimpleCalendar.DAY_OF_MONTH, 5);
System.out.println("Datum in 5 Tagen:");
System.out.println(simpleCalendar.getFormattedDate());
}
}

Binary file not shown.

View file

@ -0,0 +1,15 @@
import java.util.GregorianCalendar;
public class SimpleCalendar extends GregorianCalendar {
public String getFormattedDate() {
int year = get(GregorianCalendar.YEAR);
int month = get(GregorianCalendar.MONTH) + 1; // Monate sind 0-basiert
int day = get(GregorianCalendar.DAY_OF_MONTH);
int hour = get(GregorianCalendar.HOUR_OF_DAY);
int minute = get(GregorianCalendar.MINUTE);
int second = get(GregorianCalendar.SECOND);
return String.format("%02d.%02d.%04d %02d:%02d:%02d", day, month, year, hour, minute, second);
}
}