blob: 886bd0b405bd3b4cee1c01590f416cab1bc17f05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package design.persistence;
import design.model.Golfer;
import java.io.IOException;
public interface PersonalDatabase {
PersonalDatabase INSTANCE = new JSONPersonalDatabase("data/personaldb.json");
Golfer[] getGolfers();
Golfer getGolfer(String name);
void addGolfer(Golfer golfer) throws IOException;
void removeGolfer(Golfer golfer) throws IOException;
void updateGolfer(Golfer golfer) throws IOException;
default Golfer loadOrCreateGolfer(String username, String fullNameIfNew, String pwIfNew) throws IOException {
Golfer g = getGolfer(username);
if (g != null)
return g;
g = new Golfer(fullNameIfNew, username, pwIfNew);
addGolfer(g);
return g;
}
}
|