销售税面试题五编码实现之展示层

Program.java:

package com.xy6.interview;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.xy6.interview.util.ProductFreeTaxTypeUtil;

/**
 * 主程序
 *
 * @author daxiang
 * @since 2014-07-17
 */
public class Program {

	private static Logger logger = Logger.getLogger(Program.class);

	/**
	 * 程序入口
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		String strLog4jFile = "G:/PROGRAM/j2ee/workspace/DemoInterview2/com/xy6/interview/config/log4j.properties";
		PropertyConfigurator.configure(strLog4jFile);
		ProductFreeTaxTypeUtil.init();
		calculateResult();
	}

	/**
	 * 展示各购物车的总税额和总价
	 */
	public static void calculateResult(){
		IProductService productService = new ProductService();
		String strFilePath;
		ProductResultForm resultForm;

		strFilePath = "G:/PROGRAM/j2ee/workspace/DemoInterview2/com/xy6/interview/data/";
		String[] strXmlFile = new String[]{"case1.xml","case2.xml","case3.xml"};
		for(String strXmlFilePath : strXmlFile){
			resultForm = new ProductResultForm();
			resultForm = productService.calcProductPrice(strFilePath + strXmlFilePath);
			logger.info(strXmlFilePath + ":");
			logger.info("total:" + resultForm.getBdTotalPrice().toString());
			logger.info("taxes:" + resultForm.getBdTotalTax().toString());
			logger.info("");
		}
	}
}
ProductForm.java:

package com.xy6.interview;

import java.math.BigDecimal;

/**
 * 商品信息表单类
 *
 * @author zhang
 * @since 2014-07-17
 */
public class ProductForm {
	/** 商品名称 */
	private String name;
	/** 商品数量 */
	private int count;
	/** 商品单价 */
	private BigDecimal unitPrice;
	/** 商品类型 */
	private String type;
	/** 是否进口 */
	private boolean imported;
	/** 商品价格 */
	private BigDecimal itemPrice;
	/** 商品税额 */
	private BigDecimal itemTax;

	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public boolean getImported() {
		return imported;
	}
	public void setImported(boolean imported) {
		this.imported = imported;
	}
	public BigDecimal getItemPrice() {
		return itemPrice;
	}
	public void setItemPrice(BigDecimal itemPrice) {
		this.itemPrice = itemPrice;
	}
	public BigDecimal getItemTax() {
		return itemTax;
	}
	public void setItemTax(BigDecimal itemTax) {
		this.itemTax = itemTax;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public BigDecimal getUnitPrice() {
		return unitPrice;
	}
	public void setUnitPrice(BigDecimal unitPrice) {
		this.unitPrice = unitPrice;
	}

	public void reset(){
		this.name = "";
		this.count = 0;
		this.unitPrice = BigDecimal.ZERO;
		this.type = "";
		this.imported = false;
		this.itemPrice = BigDecimal.ZERO;
		this.itemTax = BigDecimal.ZERO;
	}

	@Override
	public String toString(){
		String strForm = "";
		strForm += "ProductForm=[\r\n";
		strForm += "this.name=" +this.name + "\r\n";
		strForm += "this.count=" +this.count + "\r\n";
		strForm += "this.unitPrice=" +this.unitPrice.toString() + "\r\n";
		strForm += "this.type=" +this.type + "\r\n";
		strForm += "this.imported=" +this.imported + "\r\n";
		strForm += "this.itemPrice=" +this.itemPrice.toString() + "\r\n";
		strForm += "this.itemTax=" +this.itemTax.toString() + "\r\n";
		strForm += "]";

		return strForm;
	}
}

ProductResultForm.java:

package com.xy6.interview;

import java.math.BigDecimal;

/**
 * 购物车表单类
 *
 * @author daxiang
 * @since 2014-07-17
 */
public class ProductResultForm {

	public ProductResultForm(){
		this.bdTotalPrice = BigDecimal.ZERO;
		this.bdTotalTax = BigDecimal.ZERO;
	}

	/** 商品总价 */
	private BigDecimal bdTotalPrice;
	/** 商品税额 */
	private BigDecimal bdTotalTax;

	public BigDecimal getBdTotalPrice() {
		return bdTotalPrice;
	}
	public void setBdTotalPrice(BigDecimal bdTotalPrice) {
		this.bdTotalPrice = bdTotalPrice;
	}
	public BigDecimal getBdTotalTax() {
		return bdTotalTax;
	}
	public void setBdTotalTax(BigDecimal bdTotalTax) {
		this.bdTotalTax = bdTotalTax;
	}

	@Override
	public String toString(){
		String strForm = "";
		strForm += "ProductResultForm=[\r\n";
		strForm += "this.bdTotalPrice=" +this.bdTotalPrice.toString() + "\r\n";
		strForm += "this.bdTotalTax=" +this.bdTotalTax.toString() + "\r\n";
		strForm += "]";

		return strForm;
	}
}


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值