package edu.mama.ls16.homework;
    import java.math.BigDecimal;
    /
    TotalAmount类用于统计
    */

    public class TotalAmount {
    private BigDecimal number; //数量
    private BigDecimal amount; //金额

    1. public TotalAmount(BigDecimal number, BigDecimal amount) {<br /> this.number = number;<br /> this.amount = amount;<br /> }<br /> public TotalAmount(String number, String amount) {<br /> this.number = new BigDecimal(number);<br /> this.amount = new BigDecimal(amount);<br /> }
    2. public BigDecimal getNumber() {<br /> return number;<br /> }
    3. public BigDecimal getAmount() {<br /> return amount;<br /> }
    4. public TotalAmount add(TotalAmount augend){<br /> return new TotalAmount(this.number.add(augend.getNumber()),this.amount.add(augend.getAmount()));<br /> }
    5. //以sep为分隔符,将TotalAmount内容拼接成字符串<br /> public String toString(String sep) {<br /> StringBuilder sb=new StringBuilder();<br /> sb.append(this.number.toString()).append(sep);<br /> sb.append(this.amount.toString());<br /> return sb.toString();<br /> }<br />}