Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class obstkorb {
  2. public static int umsatz;
  3. public int[][]array;
  4.  
  5. public obstkorb(int n) {
  6. array = new int[n][2];
  7. for(int i = 0; i<array.length; i++) {
  8. for(int j = 0; j<array[i].length; j++) {
  9. if(j == 0) {
  10. array[i][0] = 1;
  11. }
  12. array[i][0] = 20-j;
  13. array[i][1] = j+1;
  14. }
  15. }
  16. }
  17.  
  18. public void verkaufe(int stückzahl, int sorte) {
  19. if(array[sorte][0] - stückzahl>0) {
  20. array[sorte][0] = array[sorte][0] - stückzahl;
  21. umsatz = array[sorte][1] * stückzahl;
  22. }
  23. else {
  24. System.out.println("Nicht mehr genug Obst");
  25. }
  26.  
  27.  
  28. }
  29.  
  30. public void neuerPreis(int sorte, int preis) {
  31. if(preis>0) {
  32. array[sorte][1] = preis;
  33.  
  34. }
  35. else {
  36. System.out.println("Der Preis muss positiv sein");
  37. }
  38. }
  39.  
  40. public void printUmsatz() {
  41. System.out.println("Umsatz bisher: " + umsatz);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement