Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.telerikacademy.cosmetics.models;
- import com.telerikacademy.cosmetics.models.products.Product;
- import sun.reflect.generics.reflectiveObjects.NotImplementedException;
- import java.util.ArrayList;
- import java.util.List;
- public class Category {
- private String name;
- private static final int MIN_CATEGORY_LENGTH = 2;
- private static final int MAX_CATEGORY_LENGTH = 15;
- private List<Product> products;
- public void setProducts(List<Product> products) {
- this.products = products;
- }
- public Category(String name) {
- if(name.length()<MIN_CATEGORY_LENGTH || name.length()>MAX_CATEGORY_LENGTH){
- throw new IllegalArgumentException("Category name should be between 2 and 15 symbols");
- }
- this.name=name;
- }
- public List<Product> getProducts() {
- return products;
- //throw new NotImplementedException();
- }
- public void addProduct(Product product) {
- //throw new NotImplementedException();
- }
- public void removeProduct(Product product) {
- //throw new NotImplementedException();
- }
- public String print() {
- return String.format("#Category:"+name,getProducts());
- //Format:
- //" #[Name] [Brand]
- // #Price: [Price]
- // #Gender: [Gender]
- // ==="
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment