Created
February 17, 2012 17:18
-
-
Save paddya/1854454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void submitSolution(String[] tokens) { | |
if(tokens.length == 4) { | |
if(!isValidNumber(tokens[1])) { | |
System.err.println("Error! Invalid task ID."); | |
return; | |
} | |
if(!isValidMatrNo(tokens[2])) { | |
System.err.println("Error! Invalid matrNo."); | |
return; | |
} | |
int matrNo = Integer.parseInt(tokens[2]); | |
int taskID = Integer.parseInt(tokens[1]); | |
String text = tokens[3]; | |
if(!praktomat.containsTask(taskID)) { | |
System.err.println("Error! Task does not exist."); | |
return; | |
} | |
if(!praktomat.containsStudent(matrNo)) { | |
System.err.println("Error! Student does not exist."); | |
return; | |
} | |
Task task = praktomat.getTask(taskID); | |
Student student = praktomat.getStudent(matrNo); | |
if(!praktomat.submitSolution(student, text, task)) { | |
System.err.println("Error! There's already a solution for this task."); | |
} | |
} else { | |
System.err.println("Error! Invalid parameter count for command 'submit'"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment