Mittwoch lesson

This commit is contained in:
sageTheDM 2024-12-19 07:51:04 +01:00
parent e0efeb82ef
commit 8901dea11b
61 changed files with 663 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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,3 @@
public abstract class Animal {
public abstract void makeSound();
}

View file

@ -0,0 +1,11 @@
public class Camel extends Animal implements Climbing {
@Override
public void makeSound() {
System.out.println("Desert Camel grumbles!");
}
@Override
public void climb() {
System.out.println("Desert Camel climbs a dune.");
}
}

View file

@ -0,0 +1,3 @@
public interface Climbing {
void climb();
}

View file

@ -0,0 +1,16 @@
public class Eagle extends Animal implements Flying, Swimming {
@Override
public void makeSound() {
System.out.println("Eagle screams!");
}
@Override
public void fly() {
System.out.println("Eagle flies high in the sky.");
}
@Override
public void swim() {
System.out.println("Eagle fishes in the water (swims...).");
}
}

View file

@ -0,0 +1,4 @@
public interface Flying {
void fly();
}

View file

@ -0,0 +1,16 @@
public class Frog extends Animal implements Swimming, Climbing {
@Override
public void makeSound() {
System.out.println("Green Frog croaks!");
}
@Override
public void swim() {
System.out.println("Green Frog swims in the pond.");
}
@Override
public void climb() {
System.out.println("Green Frog climbs a tree.");
}
}

View file

@ -0,0 +1,3 @@
public interface Swimming {
void swim();
}

View file

@ -0,0 +1,17 @@
public class ZooTest {
public static void main(String[] args) {
Animal eagle = new Eagle();
eagle.makeSound();
((Eagle) eagle).fly();
((Eagle) eagle).swim();
Animal frog = new Frog();
frog.makeSound();
((Frog) frog).swim();
((Frog) frog).climb();
Animal camel = new Camel();
camel.makeSound();
((Camel) camel).climb();
}
}