Skip to content

Commit a44f32a

Browse files
committed
iluwatar#84 Work on data layer
1 parent d1bc28b commit a44f32a

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.iluwatar.layers;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.OneToMany;
10+
import javax.persistence.OneToOne;
11+
12+
@Entity
13+
public class Cake {
14+
15+
@Id
16+
@GeneratedValue
17+
private Long id;
18+
19+
@OneToMany
20+
private List<CakeLayer> layers;
21+
22+
@OneToOne
23+
private CakeTopping topping;
24+
25+
public Cake() {
26+
layers = new ArrayList<>();
27+
}
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.iluwatar.layers;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
7+
@Entity
8+
public class CakeLayer {
9+
10+
@Id
11+
@GeneratedValue
12+
private Long id;
13+
14+
private String name;
15+
16+
private int calories;
17+
18+
public CakeLayer() {
19+
}
20+
21+
public CakeLayer(String name, int calories) {
22+
this.name = name;
23+
this.calories = calories;
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.iluwatar.layers;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
7+
@Entity
8+
public class CakeTopping {
9+
10+
@Id
11+
@GeneratedValue
12+
private Long id;
13+
14+
private String name;
15+
16+
private int calories;
17+
18+
public CakeTopping() {
19+
}
20+
21+
public CakeTopping(String name, int calories) {
22+
this.name = name;
23+
this.calories = calories;
24+
}
25+
}

0 commit comments

Comments
 (0)