Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bill class for TestBill
- public class Bill {
- private String biller; //Person owed
- private String billAcct; //Account to be paid to
- private double billAmtDue; //Amount due
- private String billDueDate; //Due date
- private String billPaidDate; //the day bill was paid or null
- //values set to null default
- public Bill() {
- biller = null;
- billAcct = null;
- billAmtDue = 0.0;
- billDueDate = null;
- billPaidDate = null;
- }
- //Bill constructor, set values for variables
- public Bill(String owedTo, String owedFor, double owedAmt, String owedWhen, String owedPaidDate) {
- setBiller(owedTo);
- setBillAcct(owedFor);
- setBillAmtDue(owedAmt);
- setBillDueDate(owedWhen);
- setBillPaidDate(owedPaidDate);
- }
- //sets the Biller value
- public final void setBiller(String owedTo) {
- biller = owedTo;
- }
- //sets billAcct value
- public final void setBillAcct(String owedFor) {
- billAcct = owedFor;
- }
- //sets billAmtDue value
- public final void setBillAmtDue(double owedAmt) {
- billAmtDue = owedAmt;
- }
- //sets BillDueDate value
- public final void setBillDueDate(String owedWhen) {
- billDueDate = owedWhen;
- }
- //sets BillPaidDate value
- public final void setBillPaidDate(String owedPaidDate) {
- billPaidDate = owedPaidDate;
- }
- //returns biller
- public final String getBiller() {
- return biller;
- }
- //returns billAcct
- public final String getBillAcct() {
- return billAcct;
- }
- //returns billAmtDue
- public final double getBillAmtDue() {
- return billAmtDue;
- }
- //returns billDueDate
- public final String getBillDueDate() {
- return billDueDate;
- }
- //returns billPaidDate
- public final String getBillPaidDate() {
- return billPaidDate;
- }
- //returns string output w/ bill information and paid status
- public String toString() {
- String output = String.format(getBiller() +" is owed $"+ getBillAmtDue() + " on account "+ getBillAcct() +" by "+ getBillDueDate()+"\n");
- if(getBillPaidDate() == null) {
- output += "This bill has not yet been paid.";
- }
- else {
- output += "This bill was paid on "+ getBillPaidDate() +".";
- }
- return output+"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement