// Retrieves employer(company) ID public String getEmployer(int ID) { try { int employerID = ID; if (employerID > 0) { if (employerID < ReadFromFile.getNumberFromFile("company.txt")) { Company[] checkEmployers = ReadFromFile.findAllCompanyData(); return checkEmployers[employerID - 1].getName(); } } } catch (NumberFormatException n) { } return ""; }
public static void main(String[] args) { String fileName = "F:/temp/newTemp.txt"; String content = "new append!"; // 按方法A追加文件 AppendToFile.appendMethodA(fileName, content); AppendToFile.appendMethodA(fileName, "append end. \n"); // 显示文件内容 ReadFromFile.readFileByLines(fileName); // 按方法B追加文件 AppendToFile.appendMethodB(fileName, content); AppendToFile.appendMethodB(fileName, "append end. \n"); // 显示文件内容 ReadFromFile.readFileByLines(fileName); }
// Retrieves Name of employee based on the id public String getName(int ID) { try { int employeeID = ID; if (employeeID > 0) { if (employeeID < ReadFromFile.getNumberFromFile("employee.txt")) { Employee[] checkEmployees = ReadFromFile.findAllEmployeeData(); return checkEmployees[employeeID - 1].getFirstName() + " " + checkEmployees[employeeID - 1].getLastName(); } } } catch (NumberFormatException n) { } return ""; }
public static void main(String[] args) { CandidateElimination ce = new CandidateElimination(); TrainingData ex = new TrainingData(); ReadFromFile rff = new ReadFromFile(); rff.initialize(); while (rff.takeNextValue(ex)) { if (ex.EnjoySport == true) ce.positiveEncounter(ex); else ce.negativeEncounter(ex); } try { rff.br.close(); } catch (Exception e) { e.printStackTrace(); } ce.display(); System.out.println("the version space is : "); ce.getVersionSpace(); }
// Retrieves all the data for the table in a 2d array public String[][] getData() { String[][] newData; String[][] evaluationResults = ReadFromFile.getEvaluationResults(); newData = new String[evaluationResults.length][5]; for (int i = 0; i < newData.length; i++) { newData[i][0] = evaluationResults[i][0]; newData[i][1] = evaluationResults[i][1]; newData[i][2] = getName(Integer.parseInt(evaluationResults[i][1])); newData[i][3] = evaluationResults[i][13]; newData[i][4] = getEmployer(Integer.parseInt(evaluationResults[i][2])); } return newData; }