Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Verwaltung {
- public static void main (String[] args){
- Fortbewegungsmittel [] FZ = new Fortbewegungsmittel [9];
- FZ[0] = new Fahrrad ("Specialized Demo", 3000.00, 9);
- FZ[1] = new Auto (200, "Mercedes SL 500", 80000.00, 350, false);
- FZ[3] = new Motorrad (300, "Yamaha", 10000.00);
- for (Fortbewegungsmittel i : FZ) {
- if (i!= null) {
- System.out.println(i.getClass().getName()+" : ");
- System.out.println (i.toString()+" ");
- }
- }
- }
- }
- public class Auto extends KFZ {
- Auto(int au, String ma, double pr, int ps, boolean cab) {
- super(au, ma, pr);
- this.leistung = ps;
- this.istCabrio = cab;
- }
- int leistung;
- boolean istCabrio;
- public String toString() {
- String str1 = "Das Auto ist ein " + this.marke+ ". Es kostet " +this.preis+ " Euro, hat eine Leistung von " +this.leistung+ " PS und hat einen Ausstoss von " +this.Ausstoss+ " mg /km.";
- String str2 = "";
- if (istCabrio == true ){
- str2 = "und es ist eine Prollschleuder";
- }else { str2 = "und es ist ein Sportwagen";
- }
- return str1+str2;
- }
- }
Add Comment
Please, Sign In to add comment