package battery.utility;


import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

// public static int MAX_LENGHT = 300000;
// Latest date is "3/5/2100  00:00"
// We have to sort Readings.csv  Z->A according to datetime before running ReadCSV

// ************Battery*********************
// public static int MAX_SENSOR = 100;
// public static int MAX_LENGHT = 10000;



public class Stock {
	
	public static int MAX_LENGHT = 1000;
	
	public static int[][] stock = new int [MAX_LENGHT][MAX_LENGHT];
	public static int row;
	public static int col;
	

	public static int[] extractStock(int stockId, int day) {
		int[] result = new int[3];
		if (day == 1){
			result[0] = 0;
			result[1] = 1;
			if (stock[stockId][result[0]]<=stock[stockId][result[1]]) {
				result[2]= result[0];
			}
			else{
				result[2]=result[1];
			}
		}
		else{
			result = extractStock(stockId,day-1);
		//	System.out.println("      Day: " +day);
		//	System.out.println("DayBuy   : " + result[0] + " Daysell  : " + result[1] + "   MinDAte: " + result[2]);
		//	System.out.println("stockBuy : " + stock[stockId][result[0]] + " stockSell: " + stock[stockId][result[1]] + "  minStock: " + stock[stockId][result[2]]);
			if (stock[stockId][day] < stock[stockId][result[2]]){
				result[2]= day;
			}
			else if ((stock[stockId][day]- stock[stockId][result[2]])> (stock[stockId][result[1]]- stock[stockId][result[0]])){
				result[0]= result[2];
				result[1]= day;
			}
		}
		return result;	
	}
	
}
