Advertisement
binibiningtinamoran

Order.Java

Jun 1st, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class Order {
  2.  
  3.     private String customerName;
  4.     private int numberOfGarments;
  5.  
  6.     public Order() {
  7.         this.customerName = "";
  8.         this.numberOfGarments = 0;
  9.     }
  10.     public Order(String customerName) {
  11.  
  12.         this(customerName, 0);
  13.     }
  14.  
  15.     public Order(String customerName, int numberOfGarments) {
  16.  
  17.         this.customerName = customerName;
  18.         this.numberOfGarments = numberOfGarments > -1 ? numberOfGarments : 0;
  19.     }
  20.  
  21.     public void setCustomerName(String customerName) {
  22.  
  23.         this.customerName = customerName;
  24.     }
  25.  
  26.     public void setNumberOfGarments(int numberOfGarments) {
  27.  
  28.         this.numberOfGarments = numberOfGarments > -1 ? numberOfGarments : 0;
  29.     }
  30.  
  31.     public String getCustomerName() {
  32.  
  33.         return this.customerName;
  34.     }
  35.  
  36.     public int getNumberOfGarments() {
  37.  
  38.         return this.numberOfGarments;
  39.     }
  40.  
  41.     public double calculateCharge(double charge) {
  42.  
  43.         return (charge > -1.0) ? (numberOfGarments * charge) : 0.0;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement