Advertisement
Guest User

Product

a guest
Feb 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package Attributes;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. /**
  7.  * Created by Carl on 2/24/2017.
  8.  */
  9. public class Product {
  10.  
  11.     final String name;
  12.     List<Attribute> attributeGroup;
  13.  
  14.     public Product(String name) {
  15.         this.name = name;
  16.         attributeGroup = new ArrayList<>();
  17.     }
  18.  
  19.     public Product(String name, Attribute attr) {
  20.         this(name);
  21.         attributeGroup.add(attr);
  22.     }
  23.  
  24.     public Product(String name, List<Attribute> attributes) {
  25.         this(name);
  26.         this.attributeGroup = attributes;
  27.     }
  28.  
  29.     @Override
  30.     public String toString() {
  31.         StringBuilder str = new StringBuilder();
  32.         str.append("[Product " + name + " Attributes");
  33.         attributeGroup.forEach(a -> str.append(a.toString()));
  34.         str.append("]");
  35.         return str.toString();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement