Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Auto {
- //Attribute
- protected int kennzeichen;
- protected String farbe;
- protected String name;
- protected int fensterAnzahl;
- protected int hoechstgeschwindigkeit;
- protected boolean tueren;
- //Konstruktor
- public Auto(String a){
- this.name = a;
- this.kennzeichen = (int) Math.floor(Math.random()*100000);
- this.farbe = "Rot";
- this.fensterAnzahl = 4;
- this.hoechstgeschwindigkeit = 180;
- this.tueren = false;
- }
- //Methoden
- public void farbe(String a){
- this.farbe = a;
- }
- public void hoechstgeschwindigkeit(int maxspeed){
- this.hoechstgeschwindigkeit = maxspeed;
- }
- public void fensterAnzahl(int a){
- this.fensterAnzahl = a;
- }
- public void tuerenZustand(boolean a){
- this.tueren = a;
- }
- }
- ********************************************************************************************************
- public class Cabrio extends Auto{
- //Attribute
- boolean dachOffen;
- //Konstruktor
- public Cabrio(String a){
- super(a);
- !dachOffen;
- }
- //Methoden
- public void dachStatus(boolean a){
- if (a)
- System.out.println("das Dach ist gerade offen.");
- else
- System.out.println("das Dach ist geschlossen.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment