You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.4 KiB

  1. package de.hs_fulda.ciip.projjpn;
  2. public class Item {
  3. private String productTitle;
  4. private String description;
  5. private int availability = 0;
  6. private float price;
  7. /**
  8. * Creation of blank Item.
  9. */
  10. public Item() {
  11. }
  12. /**
  13. * Creation of Item.
  14. * @param titel
  15. * @param description
  16. * @param quantity
  17. * @param price
  18. */
  19. public Item(String titel,
  20. String description,
  21. int quantity,
  22. float price) {
  23. this.productTitle = titel;
  24. this.description = description;
  25. this.availability = quantity;
  26. this.price = price;
  27. }
  28. /**
  29. *
  30. * @return true if at least one item is in stock.
  31. */
  32. public boolean inStock() {
  33. return availability > 0;
  34. }
  35. /**
  36. *
  37. * @return current number of this items
  38. */
  39. public float getCurrentStock() {
  40. return availability;
  41. }
  42. /**
  43. *
  44. * @param newAmount of items
  45. */
  46. public void updateAvailability(int newAmount) {
  47. availability = newAmount;
  48. }
  49. /**
  50. *
  51. * @param newPrice of this item.
  52. */
  53. public void updatePrice(float newPrice) {
  54. this.price = newPrice;
  55. }
  56. /**
  57. *
  58. * @return Current Price of the Item.
  59. */
  60. public float getCurrentPrice() {
  61. return price;
  62. }
  63. /**
  64. *
  65. * @return Current public Title of this Item.
  66. */
  67. public String getTitel() {
  68. return this.productTitle;
  69. }
  70. /**
  71. *
  72. * @return Current public Description of this Item.
  73. */
  74. public String getDescription() {
  75. return this.description;
  76. }
  77. }