Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.time.LocalDate;
  2.  
  3. public class Program
  4. {
  5. public static void main(String[] args)
  6. {
  7. shop[] food = new shop[2];
  8. food[0] = new shop("Pomidor", 1.59,04, 03);
  9. food[1] = new shop("Banan", 2.39,04, 01);
  10. for(shop que: food)
  11. {
  12. System.out.println("Nazwa produktu = " + que.getName() + ", Cena = " + que.getPrice() + ", Data produkcji = " + que.getDay());
  13. }
  14. }
  15. }
  16.  
  17. class shop
  18. {
  19. private String name;
  20. private double price;
  21. private LocalDate date;
  22.  
  23. public shop(String class_name, double class_price, int month, int day)
  24. {
  25. name = class_name;
  26. price = class_price;
  27. date = LocalDate.of(month, day);
  28. }
  29.  
  30. public String getName()
  31. {
  32. return name;
  33. }
  34.  
  35. public double getPrice()
  36. {
  37. return price;
  38. }
  39.  
  40. public LocalDate getDay()
  41. {
  42. return date;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement