SHARE
TWEET

Untitled

a guest Sep 15th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Bill class for TestBill
  2. public class Bill {
  3.   private String biller; //Person owed
  4.   private String billAcct; //Account to be paid to
  5.   private double billAmtDue; //Amount due
  6.   private String billDueDate; //Due date
  7.   private String billPaidDate; //the day bill was paid or null
  8.  
  9.   //values set to null default
  10.   public Bill() {
  11.     biller = null;
  12.     billAcct = null;
  13.     billAmtDue = 0.0;
  14.     billDueDate = null;
  15.     billPaidDate = null;
  16.   }
  17.  
  18.   //Bill constructor, set values for variables
  19.   public Bill(String owedTo, String owedFor, double owedAmt, String owedWhen, String owedPaidDate) {
  20.     setBiller(owedTo);
  21.     setBillAcct(owedFor);
  22.     setBillAmtDue(owedAmt);
  23.     setBillDueDate(owedWhen);
  24.     setBillPaidDate(owedPaidDate);
  25.      
  26.   }
  27.  
  28.   //sets the Biller value
  29.   public final void setBiller(String owedTo) {
  30.     biller = owedTo;
  31.   }
  32.  
  33.   //sets billAcct value
  34.   public final void setBillAcct(String owedFor) {
  35.     billAcct = owedFor;
  36.   }
  37.  
  38.   //sets billAmtDue value
  39.   public final void setBillAmtDue(double owedAmt) {
  40.     billAmtDue = owedAmt;
  41.   }
  42.  
  43.   //sets BillDueDate value
  44.   public final void setBillDueDate(String owedWhen) {
  45.     billDueDate = owedWhen;
  46.   }
  47.  
  48.   //sets BillPaidDate value
  49.   public final void setBillPaidDate(String owedPaidDate) {
  50.     billPaidDate = owedPaidDate;
  51.   }
  52.  
  53.   //returns biller
  54.   public final String getBiller() {
  55.     return biller;
  56.   }
  57.  
  58.   //returns billAcct
  59.   public final String getBillAcct() {
  60.     return billAcct;
  61.   }
  62.  
  63.   //returns billAmtDue
  64.   public final double getBillAmtDue() {
  65.     return billAmtDue;
  66.   }
  67.  
  68.   //returns billDueDate
  69.   public final String getBillDueDate() {
  70.     return billDueDate;
  71.   }
  72.  
  73.   //returns billPaidDate
  74.   public final String getBillPaidDate() {
  75.     return billPaidDate;
  76.   }
  77.  
  78.   //returns string output w/ bill information and paid status
  79.   public String toString() {
  80.     String output = String.format(getBiller() +" is owed $"+ getBillAmtDue() + " on account "+ getBillAcct() +" by "+ getBillDueDate()+"\n");
  81.     if(getBillPaidDate() == null) {
  82.       output += "This bill has not yet been paid.";
  83.     }
  84.     else {
  85.      output += "This bill was paid on "+ getBillPaidDate() +".";
  86.     }
  87.     return output+"\n";
  88.   }
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top