Arbeitsblätter und Lösungen Hr. Kimmig
package autohaus;
public class Main {
public static void main(String[] args) {
// erstelle zwei Autos
Auto yaris = new Auto("Toyota Yaris","weiß",13000);
Auto tesla = new Auto("Tesla S","schwarz",96500);
// erstelle die "Person" Autohaus
Person autohaus = new Person("Autohaus");
// erstelle Person 1
Person nico = new Person("Nico");
// und zahle auf deren Konto 20000€ ein
// mit nico.getKonto() bekommt man das Konto, das zum Objekt nico gehört
// dieses Konto hat eine Methode "Einzahlen"
nico.getKonto().Einzahlen(20000);
// erstelle Person 2
Person gabriel = new Person("Gabriel");
// Person 1 kauft Yaris
nico.kaufeAuto(yaris, autohaus);
// Person 2 will Tesla kaufen -> hat zu wenig Geld, Hinweis auf der Konsole
gabriel.kaufeAuto(tesla, autohaus);
}
}