RU


SUBMITTED BY: bitcoinsachen

DATE: April 5, 2017, 12:08 p.m.

UPDATED: May 5, 2017, 6:54 p.m.

FORMAT: Text only

SIZE: 1.4 kB

HITS: 842

  1. package domain.product;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. public class JointProduct extends Product {
  5. public float discountPercentage;
  6. public Collection<Product> Products = new ArrayList<Product>();
  7. public JointProduct(String name, float discountPercentage){
  8. super(name);
  9. super.name = name;
  10. super.price = 0;
  11. this.discountPercentage = discountPercentage;
  12. }
  13. /*public JointProduct(String name, float discountPercentage,Collection<Product> products){
  14. }*/
  15. public void addProduct(Product product){
  16. if(product != null){
  17. Products.add(product);
  18. }
  19. }
  20. public boolean removeProduct(Product product){
  21. if(product != null){
  22. Products.remove(product);
  23. return true;
  24. }
  25. else{
  26. return false;
  27. }
  28. }
  29. /*public Collection<Product> getProducts(){
  30. }*/
  31. public float getPrice(){
  32. return this.getPrice();
  33. }
  34. public String toString(){
  35. return "JointProduct [name="+this.name+",price="+this.price+",discountPercentage="+this.discountPercentage+"]";
  36. }
  37. @Override
  38. public JointProduct deepCopy() {
  39. // TODO Auto-generated method stub
  40. JointProduct Copy = new JointProduct("name",0);
  41. Copy.name = this.name;
  42. Copy.price = this.price;
  43. Copy.discountPercentage = this.discountPercentage;
  44. return Copy;
  45. }
  46. }

comments powered by Disqus