Advertisement
aironman

Product

Dec 12th, 2019
181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.UUID;
  3.  
  4. public class Product {
  5.  
  6. private String id;
  7. private String description;
  8. private double prize;
  9. private boolean imported;
  10. private boolean tax_exempt;
  11. private double sale_tax;
  12.  
  13. public Product(String description, double prize) {
  14. super();
  15. this.id=UUID.randomUUID().toString();
  16. this.description = description;
  17. this.prize = prize;
  18. this.tax_exempt = description.matches("(.*)book(.*)") ||
  19. description.matches("(.*)food(.*)") ||
  20. description.matches("(.*)medical(.*)");
  21.  
  22. this.imported = description.matches("(.*)imported(.*)");
  23.  
  24. }
  25.  
  26. public double getPrize() {
  27. return prize;
  28. }
  29.  
  30. public boolean isImported() {
  31. return imported;
  32. }
  33.  
  34.  
  35. public boolean isTax_exempt() {
  36. return tax_exempt;
  37. }
  38.  
  39. public double getSale_tax() {
  40. return sale_tax;
  41. }
  42.  
  43. public void setSale_tax(double sale_tax) {
  44. this.sale_tax = sale_tax;
  45. }
  46.  
  47. @Override
  48. public String toString() {
  49. StringBuilder builder = new StringBuilder();
  50. builder.append("Product [id=").append(id).append(", description=").append(description).append(", prize=")
  51. .append(prize).append(", imported=").append(imported).append(", tax_exempt=").append(tax_exempt)
  52. .append(", sale_tax=").append(sale_tax).append("]");
  53. return builder.toString();
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement