Expose a read-only quote total
Apex properties expose a value through get and set, and a getter-only property returns a derived value.
Your task
Finish the total getter and changeSubtotal, then print three totals.
class RenewalQuote {
public Decimal subtotal { get; private set; }
public Decimal total {
get {
return 0;
}
}
public RenewalQuote(Decimal subtotal) {
this.subtotal = subtotal;
}
public void changeSubtotal(Decimal newSubtotal) {
}
}Requirements
- Direct subtotal assignment should be absent
- changeSubtotal body should be present
- Total getter should be present
- Initial total should be
Initial total: 108.00 - Updated total should be
Updated total: 270.00 - Zero-subtotal total should be
Zero subtotal: 0.00 - new RenewalQuote(19.99).total should be
21.59