Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. public class Gerichte {
  2.    
  3.     private double preis;
  4.     private static int anzahlVerkauft = 0;
  5.    
  6.     public Gerichte(double preis) {
  7.         this.preis = preis;
  8.         anzahlVerkauft++;
  9.     }
  10.    
  11.     public static int getGesamtAnzahl() {
  12.         return anzahlVerkauft;
  13.     }
  14.    
  15.     public double getPreis() {
  16.         return preis;
  17.     }
  18. }
  19.  
  20.  
  21. public class Hauptgericht extends Gerichte {
  22.    
  23.     private static int anzahlVerkauft = 0;
  24.    
  25.     public Hauptgericht() {
  26.         super(2.90);
  27.         anzahlVerkauft++;
  28.     }
  29.    
  30.     public static int getAnzahl() {
  31.         return anzahlVerkauft;
  32.     }
  33. }
  34.  
  35.  
  36. public class Nachtisch extends Gerichte {
  37.    
  38.     private static int anzahlVerkauft = 0;
  39.    
  40.     public Nachtisch() {
  41.         super(0.60);
  42.         anzahlVerkauft++;
  43.     }
  44.    
  45.     public static int getAnzahl() {
  46.         return anzahlVerkauft;
  47.     }
  48. }
  49.  
  50.  
  51. public class Salat extends Gerichte {
  52.  
  53.     private static int anzahlVerkauft = 0;
  54.  
  55.     public Salat(double gewicht) {
  56.         super((gewicht / 100 * 0.3));
  57.         anzahlVerkauft++;
  58.     }
  59.  
  60.     public static int getAnzahl() {
  61.         return anzahlVerkauft;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement