Guest User

random

a guest
Dec 1st, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1.  
  2. public class Auto {
  3. //Attribute
  4. protected int kennzeichen;
  5. protected String farbe;
  6. protected String name;
  7. protected int fensterAnzahl;
  8. protected int hoechstgeschwindigkeit;
  9. protected boolean tueren;
  10.  
  11. //Konstruktor
  12. public Auto(String a){
  13. this.name = a;
  14. this.kennzeichen = (int) Math.floor(Math.random()*100000);
  15. this.farbe = "Rot";
  16. this.fensterAnzahl = 4;
  17. this.hoechstgeschwindigkeit = 180;
  18. this.tueren = false;
  19. }
  20.  
  21. //Methoden
  22. public void farbe(String a){
  23. this.farbe = a;
  24. }
  25.  
  26. public void hoechstgeschwindigkeit(int maxspeed){
  27. this.hoechstgeschwindigkeit = maxspeed;
  28. }
  29.  
  30. public void fensterAnzahl(int a){
  31. this.fensterAnzahl = a;
  32. }
  33.  
  34. public void tuerenZustand(boolean a){
  35. this.tueren = a;
  36. }
  37. }
  38.  
  39. ********************************************************************************************************
  40.  
  41. public class Cabrio extends Auto{
  42. //Attribute
  43. boolean dachOffen;
  44.  
  45. //Konstruktor
  46. public Cabrio(String a){
  47. super(a);
  48. !dachOffen;
  49. }
  50.  
  51. //Methoden
  52. public void dachStatus(boolean a){
  53. if (a)
  54. System.out.println("das Dach ist gerade offen.");
  55. else
  56. System.out.println("das Dach ist geschlossen.");
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment