function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) { this.companyName = companyName; this.subjectName = subjectName; this.subjectFullname = companyName + " " + subjectName; this.timeLimit = timeLimit; this.maxScore = maxScore; this.gradeList = gradeList; } LicenseCompanySubjectData.prototype.getGrade = function(score) { var count = this.gradeList.length; for(var i = 0; i < count; i++) { if(score >= this.gradeList[i].score) return this.gradeList[i].grade; } return "-"; } function LicenseDataManager() { this.companies = []; this.subjects = []; // console.log(licenseDataList); this.maxSubjectCount = 0; for(var i = 0; i < licenseDataList.length; i++) { this.companies[i] = licenseDataList[i].companyName; var subjectCount = 0; var companyData = licenseDataList[i]; // console.log(companyData); var subjectData = companyData.subjectData; // console.log(subjectData); for(var j = 0; j < subjectData.length; j++) { var subjectList = subjectData[j].subjects; subjectCount += subjectList.length; for(var k = 0; k < subjectList.length; k++) { var licenseCompnaySubjectItem = new LicenseCompanySubjectData( this.companies[i], subjectList[k], companyData.subjectData[j].timeLimit, companyData.subjectData[j].maxScore, companyData.subjectData[j].gradeList ); this.subjects.push(licenseCompnaySubjectItem); } } if(subjectCount > this.maxSubjectCount) this.maxSubjectCount = subjectCount; } // console.log(this.companies); // console.log(this.subjects); // console.log(this.maxSubjectCount); } LicenseDataManager.prototype.getCompanyCount = function() { return this.companies.length; } LicenseDataManager.prototype.getCompanyList = function() { return null; } LicenseDataManager.prototype.getCompanyName = function(index) { return this.companies[index]; } LicenseDataManager.prototype.hasCompany = function(companyName) { for(var i = 0; i < this.companies.length; i++) { if(this.companies[i].companyName == companyName) return true; } return false; } LicenseDataManager.prototype.getSubjectCount = function() { return this.subjects.length; } LicenseDataManager.prototype.getSubjectDataByIndex = function(index) { return this.subjects[index]; } LicenseDataManager.prototype.getSubjectDataByName = function(subjectFullname) { for(var i = 0; i < this.subjects.length; i++) { var subjectData = this.subjects[i]; if(subjectData.subjectFullname == subjectFullname) return subjectData; } return null; } LicenseDataManager.prototype.getGrade = function(subjectData) { var companySubjectData = this.getCompanySubjectData(subjectName); console.log(companySubjectData); // if(companySubjectData != null) { // if(score > companySubjectData.gradeList[0].) // } }