Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bill subclass
- public class VariableBill extends Bill
- {
- private String variableBillDesc; //describes expense
- private String variableBillDetails; //description of bills details
- //all variables set to neutral default values
- public VariableBill()
- {
- variableBillDesc = null;
- variableBillDetails = null;
- }
- //constructor for VariableBill object, sets values for variables
- public VariableBill(String owedTo, String owedFor, double owedAmt, String owedWhen, String owedPaidDate,
- String owedDesc, String owedDetails)
- {
- setBiller(owedTo);
- setBillAcct(owedFor);
- setBillAmtDue(owedAmt);
- setBillDueDate(owedWhen);
- setVariableBillDesc(owedDesc);
- setBillPaidDate(owedPaidDate);
- setVariableBillDetails(owedDetails);
- }
- //sets variableBillDesc
- public final void setVariableBillDesc(String owedDesc)
- {
- variableBillDesc = owedDesc;
- }
- //sets variableBillDetails
- public final void setVariableBillDetails(String owedDetails)
- {
- variableBillDetails = owedDetails;
- }
- //returns variableBillDesc
- public final String getVariableBillDesc()
- {
- return variableBillDesc;
- }
- //returns variableBillDetails
- public final String getVariableBillDetails()
- {
- return variableBillDetails;
- }
- //returns string output containing bill information, paid status, and its detailed info
- public String toString()
- {
- String output = String.format(getBiller() + " is owed $" + getBillAmtDue() +" on account " + getBillAcct()+ " by " + getBillDueDate()+"\n");
- if(getBillPaidDate() == null) //checks if bill has been paid
- {
- output += "This bill has not yet been paid.";
- } else
- {
- output += "This bill was paid on "+ getBillPaidDate() +".";
- }
- output += "\nThis bill is for " + getVariableBillDesc() + ". The change from last month is due to " + getVariableBillDetails() + ".\n";
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement