package classes.comparator;

import java.util.Comparator;

import classes.HolonBattery;

public class WeakestBattery implements Comparator<HolonBattery>{
	int timeStep = 0;
	 public WeakestBattery(int compareAtTimeStep) {
	        timeStep = compareAtTimeStep;
	    }
	@Override
	public int compare(HolonBattery o1, HolonBattery o2) {
		//Sort Battery by the value of StateOfCharge/Capasity
		float O1capasity = o1.getCapacity();		
		float O2capasity = o2.getCapacity();
		if(O1capasity == 0)
		{
			return 1; 
		}
		else if(O2capasity == 0)
		{
			return -1;
		}
		if (o1.getStateOfChargeAtTimeStep(timeStep-1) / O1capasity < o2.getStateOfChargeAtTimeStep(timeStep-1) / O2capasity)
		{
			return -1;
		}else if(o1.getStateOfChargeAtTimeStep(timeStep-1) / O1capasity > o2.getStateOfChargeAtTimeStep(timeStep-1) / O2capasity)
		{
			return 1;
		}
		return 0;
	}

}
