Edit Autoradio

This commit is contained in:
Gabriel Sellmer 2021-04-09 20:08:18 +02:00
parent ff367a664b
commit e8ed1dc746
3 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,7 @@ public class Auto {
public String farbe;
public int tueren;
public List<Rad> 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(){

View File

@ -0,0 +1,11 @@
package com.p4ddy.java_tutorial;
public class Autoradio {
public String sender;
public Autoradio (){
this.sender = "RadioBoB";
}
}

View File

@ -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();