AHHHHHHHHHH COMMITED TO GITHUB INSTEAD OF FORGEJO FOR WEEKS

This commit is contained in:
sageTheDM 2024-12-16 20:32:46 +01:00
parent d6ef44f3d1
commit 0919005cb2
163 changed files with 3875 additions and 47 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.

View file

@ -0,0 +1,21 @@
import java.util.ArrayList;
import java.util.Arrays;
public class App {
public static void main(String[] args) throws Exception {
ArrayList<Article> list = new ArrayList<Article>();
list.add(new Book("11241", 12, "Tolkien", "The Book to rule all books"));
list.add(new Camera("0101012", 25000, "Fujifilm"));
list.add(new CD("0345678", 56789, "hello",
new ArrayList<String>(Arrays.asList("Hello", "World", "THIS IS THE END"))));
list.add(new MP3("RASPUTIN", 456789, "Rasputin", "lengh"));
for (Article article : list) {
article.print();
if (article instanceof CD) {
((CD) article).playTrack();
}
System.out.println();
}
}
}

View file

@ -0,0 +1,16 @@
public abstract class Article {
String code;
double price;
public Article(String code, double price) {
this.code = code;
this.price = price;
}
boolean available() {
boolean maybe = true;
return maybe;
}
abstract void print();
}

View file

@ -0,0 +1,11 @@
public abstract class Audio extends Article {
String title;
public Audio(String code, double price, String title) {
super(code, price);
this.title = title;
}
abstract void print();
}

View file

@ -0,0 +1,16 @@
public class Book extends Article {
String author;
String title;
public Book(String code, double price, String author, String title) {
super(code, price);
this.author = author;
this.title = title;
}
@Override
void print() {
System.out.println(this.author + " - " + this.title);
System.out.println("Code: " + super.code + "\nPrice: " + super.price);
}
}

View file

@ -0,0 +1,27 @@
import java.util.ArrayList;
public class CD extends Audio {
ArrayList<String> tracks = new ArrayList<>();
public CD(String code, double price, String title, ArrayList<String> tracks) {
super(code, price, title);
this.tracks = tracks;
}
@Override
void print() {
System.out.println("Title: " + title);
System.out.println("Code: " + super.code + "\nPrice: " + super.price);
for (String string : tracks) {
System.out.println(string);
}
}
void playTrack() {
int i = 1;
for (String string : tracks) {
System.out.println("Play track " + i + " " + string + " der CD " + title);
i++;
}
}
}

View file

@ -0,0 +1,14 @@
public class Camera extends Article {
String brand;
public Camera(String code, double price, String brand) {
super(code, price);
this.brand = brand;
}
@Override
void print() {
System.out.println("Brand: " + this.brand);
System.out.println("Code: " + super.code + "\nPrice: " + super.price);
}
}

View file

@ -0,0 +1,15 @@
public class MP3 extends Audio {
String lengh;
public MP3(String code, double price, String title, String lengh) {
super(code, price, title);
this.lengh = lengh;
}
@Override
void print() {
System.out.println("Title: " + title);
System.out.println("Code: " + super.code + "\nPrice: " + super.price);
System.out.println("Lengh: " + lengh + " (this was not my typo i was forced to do this)");
}
}