Skip to content

Commit

Permalink
Removed old code remaining of the film director
Browse files Browse the repository at this point in the history
  • Loading branch information
UO289845 committed Apr 18, 2024
1 parent 2aef92a commit e807bf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import main.java.questionGenerator.entityGenerator.EntityGenerator;
import main.java.questionGenerator.generator.Generator;
import main.java.questionGenerator.generator.specificGenerators.CapitalGenerator;
import main.java.questionGenerator.generator.specificGenerators.FilmDirectorGenerator;
import main.java.questionGenerator.generator.specificGenerators.DirectorGenerator;
import main.java.questionGenerator.generator.specificGenerators.HeadOfGovernmentGenerator;
import main.java.questionGenerator.generator.specificGenerators.LanguageGenerator;
import main.java.questionGenerator.generator.specificGenerators.PopulationGenerator;
Expand Down Expand Up @@ -85,7 +85,7 @@ private void setGenerator(QuestionType type) {
break;
}
case DIRECTOR: {
generator = new FilmDirectorGenerator();
generator = new DirectorGenerator();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,27 @@
public abstract class AnswersAreEntitiesWithoutSubProperties extends AbstractAnswersAreEntites {

private static final String INSTANCE_OF_PROPERTY = "P31";
private String instanceOf;

public AnswersAreEntitiesWithoutSubProperties(String propertyId, QuestionType type, String message,
String instanceOfPropertyValue) {
public AnswersAreEntitiesWithoutSubProperties(String propertyId, QuestionType type, String message) {
super(propertyId, type, message);
this.instanceOf = instanceOfPropertyValue;
}

@Override
public String getRightAnswer(Map<String, List<Statement>> claims) throws Exception {
if(claims.get(super.getPropertyId())==null) {
throw new Exception("Claims does not have the property " + super.getPropertyId());
}

String value = processRightAnswer(claims.get(INSTANCE_OF_PROPERTY).get(0));
if(!value.equals(instanceOf)) {
throw new RuntimeException("The entity is not a " + instanceOf);
}

List<Statement> stms = claims.get(getPropertyId());
Statement stm = stms.get(stms.size()-1);
return processRightAnswer(stm);
}

@Override
public String getQuestion(String name, Map<String, List<Statement>> claims) {
String value = processRightAnswer(claims.get(INSTANCE_OF_PROPERTY).get(0));
String q = getMessages().getString(getMessage());
return String.format(q, value, name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import main.java.questionGenerator.generator.AnswersAreEntitiesWithoutSubProperties;
import main.java.questionGenerator.question.QuestionType;

public class FilmDirectorGenerator extends AnswersAreEntitiesWithoutSubProperties{
public class DirectorGenerator extends AnswersAreEntitiesWithoutSubProperties{

private final static String PROPERTY = "P57";
private final static String MESSAGE = "question.director";
private final static String INSTANCE_OF = "film";

public FilmDirectorGenerator() {
super(PROPERTY, QuestionType.DIRECTOR, MESSAGE, INSTANCE_OF);
public DirectorGenerator() {
super(PROPERTY, QuestionType.DIRECTOR, MESSAGE);
}

}

0 comments on commit e807bf1

Please sign in to comment.