Add: LicenseDataManager
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) {
|
||||
this.companyName = companyName;
|
||||
this.subjectName = subjectName;
|
||||
this.timeLimit = timeLimit;
|
||||
this.maxScore = maxScore;
|
||||
this.gradeList = gradeList;
|
||||
}
|
||||
|
||||
LicenseCompanySubjectData.prototype.isNameOf = function(companySubjectName) {
|
||||
var name = this.companyName + " " + this.subjectName;
|
||||
if(name == companySubjectName)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function LicenseDataManager() {
|
||||
this.licenseCompanies = [];
|
||||
this.licenseSubjects = [];
|
||||
|
||||
// console.log(licenseCompanySubjectList);
|
||||
this.maxSubjectCount = 0;
|
||||
for(var i = 0; i < licenseCompanySubjectList.length; i++) {
|
||||
this.licenseCompanies[i] = licenseCompanySubjectList[i].companyName;
|
||||
|
||||
var subjectCount = 0;
|
||||
var companyData = licenseCompanySubjectList[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.licenseCompanies[i],
|
||||
subjectList[k],
|
||||
companyData.subjectData[j].timeLimit,
|
||||
companyData.subjectData[j].maxScore,
|
||||
companyData.subjectData[j].gradeList
|
||||
);
|
||||
|
||||
this.licenseSubjects.push(licenseCompnaySubjectItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(subjectCount > this.maxSubjectCount)
|
||||
this.maxSubjectCount = subjectCount;
|
||||
}
|
||||
|
||||
// console.log(this.licenseCompanies);
|
||||
// console.log(this.licenseSubjects);
|
||||
// console.log(this.maxSubjectCount);
|
||||
}
|
||||
|
||||
|
||||
LicenseDataManager.prototype.getCompanyCount = function() {
|
||||
return this.licenseCompanies.length;
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getCompanyList = function() {
|
||||
return null;
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getCompanyName = function(index) {
|
||||
return this.licenseCompanies[index];
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.hasCompany = function(companyName) {
|
||||
for(var i = 0; i < this.licenseCompanies.length; i++) {
|
||||
if(this.licenseCompanies[i].companyName == companyName)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getSubjectCount = function() {
|
||||
return this.licenseSubjects.length;
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getSubjectDataByIndex = function(index) {
|
||||
return this.licenseSubjects[index];
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getSubjectDataByName = function(companySubjectName) {
|
||||
for(var i = 0; i < this.licenseSubjects.length; i++) {
|
||||
var subjectData = this.licenseSubjects[i];
|
||||
if(subjectData.isNameOf(companyName))
|
||||
return subjectData;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
LicenseDataManager.prototype.getGrade = function(companySubjectName, score) {
|
||||
var companySubjectData = this.getCompanySubjectData(companySubjectName);
|
||||
console.log(companySubjectData);
|
||||
// if(companySubjectData != null) {
|
||||
// if(score > companySubjectData.gradeList[0].)
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user