aneliyanestorova

Category

Jun 13th, 2019
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. package com.telerikacademy.cosmetics.models;
  2.  
  3. import com.telerikacademy.cosmetics.models.products.Product;
  4. import sun.reflect.generics.reflectiveObjects.NotImplementedException;
  5.  
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9. public class Category {
  10. private String name;
  11. private static final int MIN_CATEGORY_LENGTH = 2;
  12. private static final int MAX_CATEGORY_LENGTH = 15;
  13.  
  14. private List<Product> products;
  15.  
  16. public void setProducts(List<Product> products) {
  17. this.products = products;
  18. }
  19. public Category(String name) {
  20. if(name.length()<MIN_CATEGORY_LENGTH || name.length()>MAX_CATEGORY_LENGTH){
  21. throw new IllegalArgumentException("Category name should be between 2 and 15 symbols");
  22. }
  23. this.name=name;
  24. }
  25.  
  26. public List<Product> getProducts() {
  27. return products;
  28.  
  29.  
  30. //throw new NotImplementedException();
  31.  
  32. }
  33.  
  34. public void addProduct(Product product) {
  35.  
  36.  
  37. //throw new NotImplementedException();
  38. }
  39.  
  40. public void removeProduct(Product product) {
  41. //throw new NotImplementedException();
  42.  
  43. }
  44.  
  45. public String print() {
  46. return String.format("#Category:"+name,getProducts());
  47.  
  48. //Format:
  49. //" #[Name] [Brand]
  50. // #Price: [Price]
  51. // #Gender: [Gender]
  52. // ==="
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment