Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bill subclass
- public class FixedBill extends Bill
- {
- private String fixedBillDesc; //description of expense
- private int fixedBillFrequency; //frequency of bill, monthly, quarterly, etc
- //variables set neutral default values
- public FixedBill()
- {
- fixedBillDesc = null;
- fixedBillFrequency = 0;
- }
- //constructor for FixedBill, sets values for variables
- public FixedBill(String owedTo, String owedFor, double owedAmt, String owedWhen, String owedPaidDate,
- String owedDesc, int owedFrequency)
- {
- setBiller(owedTo);
- setBillAcct(owedFor);
- setBillAmtDue(owedAmt);
- setBillDueDate(owedWhen);
- setFixedBillDesc(owedDesc);
- setBillPaidDate(owedPaidDate);
- setFixedBillFrequency(owedFrequency);
- }
- //returns fixedBillFrequency text description
- public String fixedBillDecodeFrequency()
- {
- //decides what to return
- switch(fixedBillFrequency)
- {
- case 1 :
- return "monthly";
- case 2 :
- return "quarterly";
- case 3 :
- return "semi-annually";
- case 4 :
- return "annually";
- default :
- return null;
- }
- }
- //sets fixedBillDesc
- public final void setFixedBillDesc(String owedDesc)
- {
- fixedBillDesc = owedDesc;
- }
- //sets fixedBillFrequency
- public final void setFixedBillFrequency(int owedFrequency)
- {
- fixedBillFrequency = owedFrequency;
- }
- //returns fixedBillDesc
- public final String getFixedBillDesc()
- {
- return fixedBillDesc;
- }
- //returns fixedBillFrequency
- public final int getFixedBillFrequency()
- {
- return fixedBillFrequency;
- }
- //returns string output containing all 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 was paid
- {
- output += "This bill has not yet been paid.";
- } else
- {
- output += "This bill was paid on "+ getBillPaidDate() +".";
- }
- output += "\nThis bill is for " + getFixedBillDesc() + " and is paid " + fixedBillDecodeFrequency() + ".\n";
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement