Guest User

Untitled

a guest
Apr 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package scotch;
  6.  
  7. /**
  8. *
  9. * @author kim-marvin.mroncz
  10. */
  11. public class Artikel {
  12.  
  13. public int artikelNr, lagerzeit;
  14. public double preis, handelsspanne, mwst;
  15. public String bezeichnung;
  16.  
  17.  
  18. public Artikel(int artikelNr, int lagerzeit, double preis, String bezeichnung) {
  19. this.artikelNr = artikelNr;
  20. this.bezeichnung = bezeichnung;
  21. this.lagerzeit = lagerzeit;
  22. this.preis = preis;
  23. handelsspanne = 0.6;
  24. mwst = 0.19;
  25. }
  26. public void anzeigen() {
  27. System.out.println(""+bezeichnung+", EK-Preis: "+preis+"€, VK-Preis: "+berechneVerkaufspreis()+" , Lagerzeit: "+lagerzeit+" Monate, Art-Nr.: "+artikelNr+"");
  28. }
  29. public int berechneVerkaufspreis() {
  30. return (int) ((preis * (1 + handelsspanne)) * (1 + mwst));
  31. }
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. /*
  61. * To change this template, choose Tools | Templates
  62. * and open the template in the editor.
  63. */
  64.  
  65. package scotch;
  66.  
  67. /**
  68. *
  69. * @author kim-marvin.mroncz
  70. */
  71. public class Sonderposten extends Artikel {
  72.  
  73. public double rabatt;
  74.  
  75. public Sonderposten(int artikelNr, int lagerzeit, double preis, String bezeichnung) {
  76. super(artikelNr,lagerzeit,preis,bezeichnung);
  77. if(lagerzeit > 12) {
  78. rabatt = 0.7;
  79. } else {
  80. rabatt = 0.9;
  81. }
  82. }
  83.  
  84. public static void main(String[] args) {
  85. Artikel a1 = new Artikel(1, 3, 10, "Scotch");
  86. Artikel a2 = new Artikel(2, 15, 55, "teurer Scotch");
  87. a1.anzeigen();
  88. a2.anzeigen();
  89. Sonderposten a3 = new Sonderposten(3,3,10,"Old Scotch");
  90. a3.anzeigen();
  91. Sonderposten a4 = new Sonderposten(4, 15, 55,"Old Scotch2");
  92. a4.anzeigen();
  93. }
  94. @Override
  95. public void anzeigen() {
  96. System.out.println("Sonderposten:");
  97. System.out.println(""+bezeichnung+", EK-Preis: "+preis+"€, VK-Preis: "+berechneVerkaufspreis()+" , Lagerzeit: "+lagerzeit+" Monate, Art-Nr.: "+artikelNr+"");
  98. }
  99. @Override
  100. public int berechneVerkaufspreis() {
  101. return (int) (((preis * (1 + handelsspanne)) * (1 + mwst)) * rabatt);
  102. }
  103.  
  104. }
Add Comment
Please, Sign In to add comment