Guest User

Untitled

a guest
Oct 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package murach.business;
  2.  
  3. import java.text.NumberFormat;
  4.  
  5.  
  6.  
  7. public class Product
  8.  
  9. {
  10.  
  11.     private String code;
  12.  
  13.     private String description;
  14.  
  15.     private double price;
  16.  
  17.  
  18.  
  19.     public Product()
  20.  
  21.     {
  22.  
  23.         code = "";
  24.  
  25.         description = "";
  26.  
  27.         price = 0;
  28.  
  29.     }
  30.  
  31.  
  32.  
  33.     public Product(String code, String description, double price)
  34.  
  35.     {
  36.  
  37.         this.code = code;
  38.  
  39.         this.description = description;
  40.  
  41.         this.price = price;
  42.  
  43.     }
  44.  
  45.  
  46.  
  47.     public void setCode(String code)
  48.  
  49.     {
  50.  
  51.         this.code = code;
  52.  
  53.     }
  54.  
  55.  
  56.  
  57.     public String getCode(){
  58.  
  59.         return code;
  60.  
  61.     }
  62.  
  63.  
  64.  
  65.     public void setDescription(String description)
  66.  
  67.     {
  68.  
  69.         this.description = description;
  70.  
  71.     }
  72.  
  73.  
  74.  
  75.     public String getDescription()
  76.  
  77.     {
  78.  
  79.         return description;
  80.  
  81.     }
  82.  
  83.  
  84.  
  85.     public void setPrice(double price)
  86.  
  87.     {
  88.  
  89.         this.price = price;
  90.  
  91.     }
  92.  
  93.  
  94.  
  95.     public double getPrice()
  96.  
  97.     {
  98.  
  99.         return price;
  100.  
  101.     }
  102.  
  103.  
  104.  
  105.     public String getFormattedPrice()
  106.  
  107.     {
  108.  
  109.         NumberFormat currency = NumberFormat.getCurrencyInstance();
  110.  
  111.         return currency.format(price);
  112.  
  113.     }
  114.  
  115.  
  116.  
  117. }
Add Comment
Please, Sign In to add comment