Skip to content

Instantly share code, notes, and snippets.

@paddya
Created February 17, 2012 17:18
Show Gist options
  • Save paddya/1854454 to your computer and use it in GitHub Desktop.
Save paddya/1854454 to your computer and use it in GitHub Desktop.
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