I need help. I am searching on the internet how to call design pattern for my code but I haven't found it. I have a class (f.e. exercise) with getter and setter and manager which have all exercise (in the DB or array, doesn't matter). In my application, I have the one instance of exercise manager and I work with exercises through it.
Exercise :
public class Exercise {
private Long id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Exercise manager:
public interface ExerciseManager{
void createExercise(Exercise exercise);
Dragon getExerciseById(Long id);
Collection<Exercise> getAllExercises();
Exercise getExerciseByName(String name);
void updateExercise(Exercise exercise);
void deleteExercise(Long id);
Boolean isIdInDB(Long id);
}
public class ExerciseManagerImpl implements ExerciseManager{
...
}
Main (f.e.):
public static void main(String[] args) {
DataSource dataSource = <some datasource>;
ExerciseManager exerciseManager = new ExerciseManagerImpl(dataSource);
Exercise newExercise = new Exercise();
newExercise.setName("Name1");
exerciseManager.createExercise(newExercise);
Exercise existExercise = exerciseManager.getExerciseByName("Name1");
exerciseManager.deleteExercise(existExercise.getId());
}
Aucun commentaire:
Enregistrer un commentaire