Guest User

Untitled

a guest
Jul 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. public class Verwaltung {
  3. public static void main (String[] args){
  4. Fortbewegungsmittel [] FZ = new Fortbewegungsmittel [9];
  5.  
  6. FZ[0] = new Fahrrad ("Specialized Demo", 3000.00, 9);
  7. FZ[1] = new Auto (200, "Mercedes SL 500", 80000.00, 350, false);
  8. FZ[3] = new Motorrad (300, "Yamaha", 10000.00);
  9.  
  10. for (Fortbewegungsmittel i : FZ) {
  11. if (i!= null) {
  12. System.out.println(i.getClass().getName()+" : ");
  13. System.out.println (i.toString()+" ");
  14.  
  15. }
  16. }
  17.  
  18. }
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25. public class Auto extends KFZ {
  26. Auto(int au, String ma, double pr, int ps, boolean cab) {
  27. super(au, ma, pr);
  28. this.leistung = ps;
  29. this.istCabrio = cab;
  30.  
  31. }
  32. int leistung;
  33. boolean istCabrio;
  34.  
  35. public String toString() {
  36. 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.";
  37. String str2 = "";
  38. if (istCabrio == true ){
  39. str2 = "und es ist eine Prollschleuder";
  40. }else { str2 = "und es ist ein Sportwagen";
  41. }
  42. return str1+str2;
  43. }
  44. }
Add Comment
Please, Sign In to add comment