function HistoryRecord(date, appName, bestRecord) {
	this.date = date;
	this.appName = appName;
	this.bestRecord = bestRecord;
}



function HistoryRecordManager() {
	this.clear();
}

HistoryRecordManager.prototype.push = function(HistoryRecord) {
	this.historyRecords.push(HistoryRecord);

	this.minValueOfRecord = this.minValueOfArray();
	this.maxValueOfRecord = this.maxValueOfArray();
}

HistoryRecordManager.prototype.clear = function() {
	this.historyRecords = [];

	this.minValueOfRecord = 0;
	this.maxValueOfRecord = 0;
}

HistoryRecordManager.prototype.getCount = function() {
	return this.historyRecords.length;
}

HistoryRecordManager.prototype.getAt = function(index) {
	return this.historyRecords[index];
}

HistoryRecordManager.prototype.getDateAt = function(index) {
	return this.historyRecords[index].date;
}

HistoryRecordManager.prototype.getAppNameAt = function(index) {
	return this.historyRecords[index].appName;
}

HistoryRecordManager.prototype.getBestRecordAt = function(index) {
	return this.historyRecords[index].bestRecord;
}

HistoryRecordManager.prototype.minValueOfArray = function() {
	var absArray = [];
	var numberArray = this.getBestRecordArray(this.historyRecords);
	for(var i = 0; i < numberArray.length; i++) {
		var data = numberArray[i];
		absArray.push(Math.abs(data));
	}

	// console.log(numberArray);
	// console.log(absArray);
	return Math.min.apply(Math, absArray);
}

HistoryRecordManager.prototype.maxValueOfArray = function() {
	var absArray = [];
	var numberArray = this.getBestRecordArray(this.historyRecords);
	for(var i = 0; i < numberArray.length; i++) {
		var data = numberArray[i];
		absArray.push(Math.abs(data));
	}

	return Math.max.apply(Math, absArray);
}

HistoryRecordManager.prototype.underValueForGraph = function() {
	// console.log("this.minValueOfRecord : " + this.minValueOfRecord);
	var minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
	var underMinValue =
		Math.floor( (this.minValueOfRecord / Math.pow(10, minNumberOfDigits - 2) ) )
		* Math.pow(10, minNumberOfDigits - 2 );
	return underMinValue;
}

HistoryRecordManager.prototype.upperValueForGraph = function() {
	var maxNumberOfDigits = NumberUtil.numberOfDigits(this.maxValueOfRecord);
	var underMaxValue =
		Math.ceil( (this.maxValueOfRecord / Math.pow(10, maxNumberOfDigits - 2) ) )
		* Math.pow(10, maxNumberOfDigits - 2);
	return underMaxValue;
}

HistoryRecordManager.prototype.getBestRecordArray = function() {
	var numberArray = [];
	// for(var data of this.historyRecords) {
	// 	numberArray.push(data.bestRecord);
	// }
	for(var i = 0; i < this.historyRecords.length; i++) {
		var data = this.historyRecords[i];
		numberArray.push(data.bestRecord);
	}
	return numberArray;
}