package com.hammurapi.test;

import java.util.Map;

public class Receipt {
	
	private String companyName;
	private double tax;
	private String promotion;
	
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}	
	
	public void setTax(Double tax) {
		this.tax = tax;
	}
	
	public void setPromotion(String promotion) {
		this.promotion = promotion;
	}
	
	public void print(Map<String, Double> items) {
		System.out.println("\t\t"+companyName);
		double total = 0;
		for (Map.Entry<String, Double> entry: items.entrySet()) {
			System.out.println(entry.getKey()+":\t"+entry.getValue());
			total+=entry.getValue();
		}
		System.out.println("---------");
		System.out.println("Tax:\t"+tax+" %");
		System.out.println("Total:\t"+total*(1+tax/100));
		if (promotion!=null) {
			System.out.println();
			System.out.println("*** "+promotion+" ***");
		}		
	}

}
