Compare commits
2 Commits
9ad62d72cc
...
9a29499c39
Author | SHA1 | Date |
---|---|---|
David Guler | 9a29499c39 | |
David Guler | 6d1fdd05ab |
|
@ -0,0 +1,12 @@
|
|||
package ch.zhaw.gartenverwaltung.io;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.UserPlanting;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface GardenPlan {
|
||||
List<UserPlanting> getPlantings();
|
||||
void savePlanting(UserPlanting planting) throws IOException;
|
||||
void removePlanting(UserPlanting planting) throws IOException;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package ch.zhaw.gartenverwaltung.io;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.Task;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskDatabase {
|
||||
List<Task> getTaskList(Date start, Date end);
|
||||
void saveTask(Task task) throws IOException;
|
||||
void removeTask(Task task) throws IOException;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package ch.zhaw.gartenverwaltung.types;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Models a Task
|
||||
* May be created using the builder pattern.
|
||||
*/
|
||||
public class Task {
|
||||
private long id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final Date startDate;
|
||||
private Integer interval;
|
||||
private Date endDate;
|
||||
|
||||
public Task(String name, String description, Date startDate) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.startDate = endDate;
|
||||
}
|
||||
|
||||
// Builder-pattern-style setters
|
||||
public Task withId(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
public Task withInterval(int interval) {
|
||||
this.interval = interval;
|
||||
return this;
|
||||
}
|
||||
public Task withEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public long getId() { return id; }
|
||||
public String getName() { return name; }
|
||||
public String getDescription() { return description; }
|
||||
public Date getStartDate() { return startDate; }
|
||||
|
||||
public Optional<Integer> getInterval() {
|
||||
return Optional.ofNullable(interval);
|
||||
}
|
||||
public Optional<Date> getEndDate() {
|
||||
return Optional.ofNullable(endDate);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package ch.zhaw.gartenverwaltung.types;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record UserPlanting(
|
||||
long plantId,
|
||||
Date startDate,
|
||||
int area
|
||||
) {
|
||||
}
|
Loading…
Reference in New Issue