zoukankan      html  css  js  c++  java
  • 简单应用单例模式

    进行参数传值及本类属性值调用

     public class TBalancesUtil {
    private double before_amount;
    private double fen_qi_amountAll;
    private double fen_qi_amount;
    private TBalances tBalances;
    private TBalances tBalancesNew;
    private TGrocery tGrocery;
    private String period_name;
    private int period_fen_qi_shu;

    public TBalancesUtil() {

    }

    private static class Inner {
    private static TBalancesUtil getInstance(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    return new TBalancesUtil(tBalances, tBalancesNew, tGrocery, period_name, period_fen_qi_shu);
    }
    }

    public static TBalancesUtil getSingle(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    return Inner.getInstance(tBalances, tBalancesNew, tGrocery, period_name, period_fen_qi_shu);
    }


    public TBalancesUtil(TBalances tBalances, TBalances tBalancesNew, TGrocery tGrocery, String period_name, int period_fen_qi_shu) {
    this.tBalances = tBalances;
    this.tBalancesNew = tBalancesNew;
    this.tGrocery = tGrocery;
    this.period_name = period_name;
    this.period_fen_qi_shu = period_fen_qi_shu;
    this.before_amount = MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getBefore_amount_rate(), tGrocery.getKeep_decimal());
    this.fen_qi_amountAll = MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getFen_qi_amount_rate(), tGrocery.getKeep_decimal());
    this.fen_qi_amount = MathUtil.divide(MathUtil.multiply(MathUtil.multiply(tBalances.getServicemoney(), tGrocery.getFixed_rate(), tGrocery.getKeep_decimal()), tGrocery.getFen_qi_amount_rate(), tGrocery.getKeep_decimal()), tBalances.getFen_qi_shu(), tGrocery.getKeep_decimal());
    }


    public TBalances firstMouth() {
    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setBefore_amount(before_amount);
    tBalancesNew.setDone_fen_qi_amount(fen_qi_amount);
    tBalancesNew.setRemained_fen_qi_shu(tBalances.getFen_qi_shu() - 1);
    tBalancesNew.setRemained_fen_qi_amount(fen_qi_amountAll - fen_qi_amount);
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setFen_qi_amount(fen_qi_amount);
    tBalancesNew.setPeriod_fen_qi_amount(fen_qi_amount);
    tBalancesNew.setPeriod_fen_qi_shu(1);
    tBalancesNew.setContract_status(1);
    return tBalancesNew;
    }


    public TBalances lastMouth() {

    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setDone_fen_qi_amount(fen_qi_amountAll);
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setBefore_amount(0.00);
    tBalancesNew.setRemained_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setRemained_fen_qi_amount(0.00);
    tBalancesNew.setFen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(fen_qi_amount, (period_fen_qi_shu - 1), 2), 2));
    tBalancesNew.setContract_status(2);
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setPeriod_fen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(fen_qi_amount, (period_fen_qi_shu - 1), 2), 2));
    tBalancesNew.setPeriod_fen_qi_shu(period_fen_qi_shu);

    return tBalancesNew;
    }


    public TBalances middleMouth() {
    tBalancesNew.setId(tBalances.getId());
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setServicemoney(tBalances.getServicemoney());

    tBalancesNew.setPeriod_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setContnum(tBalances.getContnum());
    tBalancesNew.setAccount_time(tBalances.getAccount_time());
    tBalancesNew.setFen_qi_shu(tBalances.getFen_qi_shu());
    tBalancesNew.setDone_fen_qi_amount(MathUtil.multiply(period_fen_qi_shu, fen_qi_amount, 2));
    tBalancesNew.setServicemoney(tBalances.getServicemoney());
    tBalancesNew.setCreate_date(tBalances.getCreate_date());
    tBalancesNew.setBefore_amount(0.00);
    tBalancesNew.setRemained_fen_qi_shu(period_fen_qi_shu);
    tBalancesNew.setRemained_fen_qi_amount(MathUtil.subtract(fen_qi_amountAll, MathUtil.multiply(period_fen_qi_shu, fen_qi_amount, 2), 2));
    tBalancesNew.setFen_qi_amount(fen_qi_amount);
    tBalancesNew.setContract_status(tBalances.getContract_status());
    tBalancesNew.setPeriod_name(period_name);
    tBalancesNew.setPeriod_fen_qi_amount(fen_qi_amount);

    return tBalancesNew;
    }

    }
  • 相关阅读:
    Access Update 不支持子查询 用查询解决
    vs2005中文乱码
    清理sql日志
    VS2005快捷键使用
    如何用C#改文件名
    C#中使用DirectSound录音
    VS2005打包 到没有.NETFramework2.0的目标机器上安装
    Access中iif,isnull的用法
    水晶报表切换字段视图不能用的问题。
    VS2005中TextBox的ReadOnly属性
  • 原文地址:https://www.cnblogs.com/Dream--/p/8478063.html
Copyright © 2011-2022 走看看