// Jeff Marinko (jeff@vhub.com)
// Example Solution for Wockets, Wackets, and Widgets Lab (CSC 101)

import java.text.DecimalFormat;

public class Wocket {

	// comment
	private int totalCount;
	// comment
	private double totalWeight;
	// not expected
	private static DecimalFormat format = new DecimalFormat("0.00");
	
	// comment
	// ignore this for now
	public Wocket() {}
	
	// comment
	public Wocket(int count, double weight) {
		if (count >= 0 && weight >= 0) {
			totalCount = count;
			totalWeight = weight;
		}
		else {
			totalCount = 0;
			totalWeight = 0;
		}
	}
	
	// comment
	public int getCount() {return totalCount;}
	// comment
	public double getWeight() {return totalWeight;}
	// comment
	public double getAvgWeight() {
		if (totalCount > 0)
			return totalWeight / totalCount;
		else
			return 0;
		
		// shorthand notation, for those interested
		//return totalCount > 0 ? totalWeight / totalCount : 0;
	}
	
	// comment
	public String toString() {
		return "Wocket: " + getCount() + " female gremlins, " +
		 format.format(getWeight()) + " weight";
	}
	
	// comment
	public void add(double newWeight) {add(1, newWeight);}
	public void add(Wocket Wocket) {add(Wocket.getCount(), Wocket.getWeight());}
	public void add(int addCount, double addWeight) {
		if (addCount > 0 && addWeight > 0) { // arguably, both should be positive
			totalCount += addCount;
			totalWeight += addWeight;
		}
		// NOTE:  Does not need an else clause
	}
}