diff --git a/Code/Steiner/oopRepetition - 24-23-10/.vscode/settings.json b/Code/Steiner/oopRepetition - 24-23-10/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/Code/Steiner/oopRepetition - 24-23-10/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Code/Steiner/oopRepetition - 24-23-10/README.md b/Code/Steiner/oopRepetition - 24-23-10/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/Code/Steiner/oopRepetition - 24-23-10/README.md @@ -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). diff --git a/Code/Steiner/oopRepetition - 24-23-10/bin/DateOfBirth.class b/Code/Steiner/oopRepetition - 24-23-10/bin/DateOfBirth.class new file mode 100644 index 0000000..e41d266 Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/bin/DateOfBirth.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/bin/Main.class b/Code/Steiner/oopRepetition - 24-23-10/bin/Main.class new file mode 100644 index 0000000..3c535b8 Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/bin/Main.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/bin/Person.class b/Code/Steiner/oopRepetition - 24-23-10/bin/Person.class new file mode 100644 index 0000000..e390955 Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/bin/Person.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/App.class b/Code/Steiner/oopRepetition - 24-23-10/src/App.class new file mode 100644 index 0000000..c6fb9ff Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/src/App.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.class b/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.class new file mode 100644 index 0000000..6336e52 Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.java b/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.java new file mode 100644 index 0000000..29c0fca --- /dev/null +++ b/Code/Steiner/oopRepetition - 24-23-10/src/DateOfBirth.java @@ -0,0 +1,33 @@ +// DateOfBirth class to manage birth date and age calculation +class DateOfBirth { + private int birthYear; + private int birthMonth; + private int birthDay; + + // Constructor + public DateOfBirth(int birthYear, int birthMonth, int birthDay) { + this.birthYear = birthYear; + this.birthMonth = birthMonth; + this.birthDay = birthDay; + } + + // Method to calculate the age based on the hardcoded current date (23.10.2024) + public int calculateAge() { + int currentYear = 2024; + int currentMonth = 10; + int currentDay = 23; + + int age = currentYear - birthYear; + + // Adjust the age if the birthday hasn't happened yet this year + if (birthMonth > currentMonth || (birthMonth == currentMonth && birthDay > currentDay)) { + age--; + } + return age; + } + + // Method to return the birth date as a string + public String getBirthDate() { + return birthDay + "." + birthMonth + "." + birthYear; + } +} \ No newline at end of file diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/Main.class b/Code/Steiner/oopRepetition - 24-23-10/src/Main.class new file mode 100644 index 0000000..3e086cd Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/src/Main.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/Main.java b/Code/Steiner/oopRepetition - 24-23-10/src/Main.java new file mode 100644 index 0000000..ca1379f --- /dev/null +++ b/Code/Steiner/oopRepetition - 24-23-10/src/Main.java @@ -0,0 +1,38 @@ +// Main class with methods to create, modify, and display a person +public class Main { + public static void main(String[] args) { + // Create a Person object with all parameters + Person person = createPerson(); + + // Print the introduction and list of information + printPersonDetails(person); + + // Modify the person and return a new object + Person updatedPerson = modifyPerson(person, "Bob", "789 Oak Street"); + + // Print the updated person information + System.out.println("\nAfter modification:"); + printPersonDetails(updatedPerson); + } + + // Method to create and return a Person object + public static Person createPerson() { + DateOfBirth dob = new DateOfBirth(1994, 6, 15); // Example birth date + return new Person("Alice", dob, "1234 Elm Street"); + } + + // Method to print a person's details + public static void printPersonDetails(Person person) { + person.introduce(); // Print the introduction + person.listInformation(); // Print the full list of details + } + + // Method to modify a person object and return the modified person (custom + // object as return type) + public static Person modifyPerson(Person originalPerson, String newName, String newAddress) { + // Modify the person's details and return the modified object + originalPerson.setName(newName); // Update the name + originalPerson.setAddress(newAddress); // Update the address + return originalPerson; // Return the modified object + } +} diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/Person.class b/Code/Steiner/oopRepetition - 24-23-10/src/Person.class new file mode 100644 index 0000000..dda51c9 Binary files /dev/null and b/Code/Steiner/oopRepetition - 24-23-10/src/Person.class differ diff --git a/Code/Steiner/oopRepetition - 24-23-10/src/Person.java b/Code/Steiner/oopRepetition - 24-23-10/src/Person.java new file mode 100644 index 0000000..2cb1de0 --- /dev/null +++ b/Code/Steiner/oopRepetition - 24-23-10/src/Person.java @@ -0,0 +1,47 @@ +// Person class that uses the DateOfBirth class +class Person { + private String name; + private DateOfBirth dateOfBirth; // Using DateOfBirth for birth date management + private String address; + + // Constructor + public Person(String name, DateOfBirth dateOfBirth, String address) { + this.name = name; + this.dateOfBirth = dateOfBirth; + this.address = address; + } + + // Method to introduce the person + public void introduce() { + System.out.println("Hi, I'm " + name + ". I was born on " + dateOfBirth.getBirthDate() + " and I am " + + dateOfBirth.calculateAge() + " years old."); + } + + // Method to list the person's details + public void listInformation() { + System.out.println("Name: " + name); + System.out.println("Birth Date: " + dateOfBirth.getBirthDate()); + System.out.println("Age: " + dateOfBirth.calculateAge()); + System.out.println("Address: " + address); + } + + // Getter for name + public String getName() { + return name; + } + + // Setter for name + public void setName(String name) { + this.name = name; + } + + // Getter for address + public String getAddress() { + return address; + } + + // Setter for address + public void setAddress(String address) { + this.address = address; + } +} \ No newline at end of file diff --git a/Notizen/Objekte als Parameter.pptx b/Notizen/Objekte als Parameter.pptx new file mode 100644 index 0000000..9bc77b6 Binary files /dev/null and b/Notizen/Objekte als Parameter.pptx differ