1 package sellwin.domain; 2 3 import java.util.*; 4 import java.io.*; 5 import java.text.*; 6 import javax.swing.text.*; 7 8 12 13 18 public class QuoteLine implements Serializable { 19 private long pk; 20 private long quotePK; 21 private Product product; 22 private Integer quantity; 23 private Double totalPrice; 24 private boolean modified; 25 private String modifiedBy; 26 private Date modifiedDate; 27 private boolean addedLocally=false; 28 private boolean updatedLocally=false; 29 30 public QuoteLine() { 31 totalPrice = new Double (12.00); 32 quantity = new Integer (1); 33 modified = false; 34 modifiedDate = new Date(); 35 } 36 37 public final void setPK(long pk) { this.pk = pk; } 38 public final void setQuotePK(long pk) { quotePK = pk; } 39 public final long getQuotePK() { return quotePK; } 40 public final Product getProduct() { return product; } 41 public final void setProduct(Product p) { product = p; } 42 public final void setQuantity(Integer d) { 43 quantity=d; 44 calcTotal(); 45 } 46 47 public final void setTotalPrice(Double d) { totalPrice = d; } 48 public final void setModified(boolean f) { modified = f; } 49 public final void setModifiedBy(String f) { modifiedBy = f; } 50 public final void setModifiedDate(Date f) { modifiedDate = f; } 51 52 53 public final long getPK() { return pk; } 54 public final Integer getQuantity() { return quantity; } 55 public final Double getTotalPrice() { return totalPrice; } 56 public final boolean getModified() { return modified; } 57 public final Date getModifiedDate() { return modifiedDate; } 58 public final String getModifiedBy() { return modifiedBy; } 59 60 public final void setUpdatedLocally(boolean b) { updatedLocally=b; } 61 public final void setAddedLocally(boolean b) { addedLocally=b; } 62 63 private final void calcTotal() { 64 double u = product.getPrice().doubleValue(); 65 int q = quantity.intValue(); 66 setTotalPrice(new Double (u * q)); 67 } 68 69 public final QuoteLine copy() { 70 QuoteLine copy = new QuoteLine(); 71 copy.product = product.copy(); 72 copy.quantity= new Integer (quantity.intValue()); 73 if (modifiedBy != null) 74 copy.modifiedBy = new String (modifiedBy); 75 copy.modifiedDate = new Date(modifiedDate.getTime()); 76 return copy; 77 } 78 79 public final void print() { 80 System.out.println("<<Quote Line>>"); 81 System.out.println("pk=["+getPK()+"]"); 82 product.print(); 83 System.out.println("Quantity="+getQuantity()); 84 System.out.println("Modified =["+getModified()+"]"); 85 System.out.println("Modified =["+modifiedBy + modifiedDate+"]"); 86 } 87 } 88 | Popular Tags |