From e8ed1dc7467ba557188db626f800740c8451d121 Mon Sep 17 00:00:00 2001 From: Gabriel Sellmer Date: Fri, 9 Apr 2021 20:08:18 +0200 Subject: [PATCH] Edit Autoradio --- .../src/com/p4ddy/java_tutorial/Auto.java | 3 +++ .../src/com/p4ddy/java_tutorial/Autoradio.java | 11 +++++++++++ .../src/com/p4ddy/java_tutorial/HelloWorld.java | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Autoradio.java diff --git a/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Auto.java b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Auto.java index 0b44b21..1b97091 100644 --- a/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Auto.java +++ b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Auto.java @@ -9,6 +9,7 @@ public class Auto { public String farbe; public int tueren; public List raeder; + public Autoradio radio; public Auto(String hersteller, int leistung, String farbe, int tueren) { this.hersteller = hersteller; @@ -26,6 +27,8 @@ public class Auto { this.raeder.add(rad2); this.raeder.add(rad3); this.raeder.add(rad4); + + this.radio = new Autoradio(); } public void fahren(){ diff --git a/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Autoradio.java b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Autoradio.java new file mode 100644 index 0000000..4c37c45 --- /dev/null +++ b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/Autoradio.java @@ -0,0 +1,11 @@ +package com.p4ddy.java_tutorial; + +public class Autoradio { + public String sender; + + public Autoradio (){ + this.sender = "RadioBoB"; + } + + +} diff --git a/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/HelloWorld.java b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/HelloWorld.java index 5cfede8..555a042 100644 --- a/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/HelloWorld.java +++ b/Gabriel-Java-Learning/src/com/p4ddy/java_tutorial/HelloWorld.java @@ -5,6 +5,8 @@ public class HelloWorld { Auto auto1 = new Auto("Tesla", 500, "Rot", 5); Auto auto2 = new Auto("Porsche", 1000, "Gelb", 3); + auto2.radio.sender = "RadioJazz"; + System.out.println("Auto soll fahren"); auto1.fahren(); auto1.fahren();