Skip to content

Commit c57b6ad

Browse files
authored
feat: adds Ezra's custom Party data type (#515)
* feat: adds Party and Vive classes with guest management functionality * feat: adds Party and Vibe classes with guest management functionality * feat: refactors Party and PartyException classes; adds unit tests for Party and Vibe * feat: refactor Party and PartyException classes; add unit tests for Party and Vibe * feat: replace PartyException with PartyCityException; update tests accordingly * Update settings.json
1 parent fd098fd commit c57b6ad

File tree

6 files changed

+420
-0
lines changed

6 files changed

+420
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
import java.util.ArrayList;
4+
5+
public class Party {
6+
7+
private String name;
8+
private String location;
9+
private String localDate;
10+
private Boolean isPrivate;
11+
private double coverCharge;
12+
private int ticketNumber;
13+
private Vibe vibe;
14+
private ArrayList<String> guestList;
15+
16+
public Party(
17+
String name,
18+
String location,
19+
String localDate,
20+
Boolean isPrivate,
21+
Double coverCharge,
22+
int ticketNumber,
23+
Vibe vibe,
24+
String[] guestList) {
25+
this.name = name;
26+
this.location = location;
27+
this.isPrivate = isPrivate;
28+
this.coverCharge = coverCharge;
29+
this.ticketNumber = ticketNumber;
30+
this.vibe = vibe;
31+
this.guestList = new ArrayList<>();
32+
}
33+
34+
public String getName() {
35+
return name;
36+
}
37+
38+
public void setName(String name) {
39+
this.name = name;
40+
}
41+
42+
public String getLocation() {
43+
return location;
44+
}
45+
46+
public void setLocation(String location) {
47+
this.location = location;
48+
}
49+
50+
public String getLocalDate() {
51+
return localDate;
52+
}
53+
54+
public void setLocalDate(String localDate) {
55+
this.localDate = localDate;
56+
}
57+
58+
public Boolean getIsPrivate() {
59+
return isPrivate;
60+
}
61+
62+
public void setIsPrivate(Boolean isPrivate) {
63+
this.isPrivate = isPrivate;
64+
}
65+
66+
public double getCoverCharge() {
67+
return coverCharge;
68+
}
69+
70+
public void setCoverCharge(double coverCharge) {
71+
this.coverCharge = coverCharge;
72+
}
73+
74+
public int getTicketNumber() {
75+
return ticketNumber;
76+
}
77+
78+
public void setTicketNumber(int ticketNumber) {
79+
this.ticketNumber = ticketNumber;
80+
}
81+
82+
public Vibe getVibe() {
83+
return vibe;
84+
}
85+
86+
public void setVibe(Vibe vibe) {
87+
this.vibe = vibe;
88+
}
89+
90+
public ArrayList<String> getGuestList() {
91+
ArrayList<String> copy = new ArrayList<>();
92+
for (String guest : guestList) {
93+
copy.add(guest);
94+
}
95+
return copy;
96+
}
97+
98+
public void setGuestList(ArrayList<String> guestList) {
99+
this.guestList = guestList;
100+
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
public class PartyCityException extends Exception {
4+
public PartyCityException(String message) {
5+
super(message);
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
public enum Vibe {
4+
CHILL,
5+
PRIVATE,
6+
ALL_WHITE,
7+
RELAXED_LOUNGE,
8+
COSTUME
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
public class PartyExceptionTest {
8+
@Test
9+
void testConstructor() {
10+
String expectedMessage = "Party is not private";
11+
PartyCityException exception = new PartyCityException(expectedMessage);
12+
String actualMessage = exception.getMessage();
13+
assertThat(actualMessage).isEqualTo(expectedMessage);
14+
}
15+
}
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import org.junit.jupiter.api.Test;
8+
9+
public class PartyTest {
10+
11+
@Test
12+
void testGetName() {
13+
Party party =
14+
new Party(
15+
"Everyday People",
16+
"Washington D.C.",
17+
"2025-06-012",
18+
false,
19+
50.0,
20+
0,
21+
Vibe.CHILL,
22+
new String[] {});
23+
String expectedName = "Everyday People";
24+
party.setName(expectedName);
25+
String actualName = party.getName();
26+
assertThat(actualName).isEqualTo(expectedName);
27+
}
28+
29+
@Test
30+
void testGetlocalDate() {
31+
Party party =
32+
new Party(
33+
"Everyday People",
34+
"Washington D.C.",
35+
"2025-06-012",
36+
false,
37+
50.0,
38+
0,
39+
Vibe.CHILL,
40+
new String[] {});
41+
String expectedDate = "2025-06-012";
42+
party.setLocalDate(expectedDate);
43+
String actualDate = party.getLocalDate();
44+
assertThat(actualDate).isEqualTo(expectedDate);
45+
}
46+
47+
@Test
48+
void testGetCoverCharge() {
49+
Party party =
50+
new Party(
51+
"Everyday People",
52+
"Washington D.C.",
53+
"2025-06-012",
54+
false,
55+
50.0,
56+
0,
57+
Vibe.CHILL,
58+
new String[] {});
59+
Double expectedCharge = 50.0;
60+
party.setCoverCharge(expectedCharge);
61+
Double actualCharge = party.getCoverCharge();
62+
assertThat(actualCharge).isEqualTo(expectedCharge);
63+
}
64+
65+
@Test
66+
void testGetVibe() {
67+
Party party =
68+
new Party(
69+
"Everyday People",
70+
"Washington D.C.",
71+
"2025-06-012",
72+
false,
73+
50.0,
74+
0,
75+
Vibe.CHILL,
76+
new String[] {});
77+
Vibe expectedVibe = Vibe.CHILL;
78+
party.setVibe(expectedVibe);
79+
Vibe actualVibe = party.getVibe();
80+
assertThat(actualVibe).isEqualTo(expectedVibe);
81+
}
82+
83+
@Test
84+
void testSetVibe() {
85+
Party party =
86+
new Party(
87+
"Everyday People",
88+
"Washington D.C.",
89+
"2025-06-012",
90+
false,
91+
50.0,
92+
0,
93+
Vibe.CHILL,
94+
new String[] {});
95+
}
96+
97+
@Test
98+
void testSetName() {
99+
Party party =
100+
new Party(
101+
"Everyday People",
102+
"Washington D.C.",
103+
"2025-06-012",
104+
false,
105+
50.0,
106+
0,
107+
Vibe.CHILL,
108+
new String[] {});
109+
String expectedName = "Everyday People";
110+
party.setName(expectedName);
111+
String actualName = party.getName();
112+
assertThat(actualName).isEqualTo(expectedName);
113+
}
114+
115+
@Test
116+
void testSetLocation() {
117+
Party party =
118+
new Party(
119+
"Everyday People",
120+
"Washington D.C.",
121+
"2025-06-012",
122+
false,
123+
50.0,
124+
0,
125+
Vibe.CHILL,
126+
new String[] {});
127+
String expectedLocation = "Brooklyn";
128+
party.setLocation(expectedLocation);
129+
String actualLocation = party.getLocation();
130+
assertThat(actualLocation).isEqualTo(expectedLocation);
131+
}
132+
133+
@Test
134+
void testGetLocation() {
135+
Party party =
136+
new Party(
137+
"Everyday People",
138+
"Washington D.C.",
139+
"2025-06-012",
140+
false,
141+
50.0,
142+
0,
143+
Vibe.CHILL,
144+
new String[] {});
145+
String expectedLocation = "Brooklyn";
146+
party.setLocation(expectedLocation);
147+
String actualLocation = party.getLocation();
148+
assertThat(actualLocation).isEqualTo(expectedLocation);
149+
}
150+
151+
@Test
152+
void testGetPrivate() {
153+
Party party =
154+
new Party(
155+
"Everyday People",
156+
"Washington D.C.",
157+
"2025-06-012",
158+
false,
159+
50.0,
160+
0,
161+
Vibe.CHILL,
162+
new String[] {});
163+
Boolean expectedPrivate = false;
164+
party.setIsPrivate(expectedPrivate);
165+
Boolean actualPrivate = party.getIsPrivate();
166+
assertThat(actualPrivate).isEqualTo(expectedPrivate);
167+
}
168+
169+
@Test
170+
void testSetPrivate() {
171+
Party party =
172+
new Party(
173+
"Everyday People",
174+
"Washington D.C.",
175+
"2025-06-012",
176+
false,
177+
50.0,
178+
0,
179+
Vibe.CHILL,
180+
new String[] {});
181+
Boolean expectedPrivate = true;
182+
party.setIsPrivate(expectedPrivate);
183+
Boolean actualPrivate = party.getIsPrivate();
184+
assertThat(actualPrivate).isEqualTo(expectedPrivate);
185+
}
186+
187+
@Test
188+
void testCoverCharge() {
189+
Party party =
190+
new Party(
191+
"Everyday People",
192+
"Washington D.C.",
193+
"2025-06-012",
194+
false,
195+
50.0,
196+
0,
197+
Vibe.CHILL,
198+
new String[] {});
199+
Double expectedCharge = 50.0;
200+
party.setCoverCharge(expectedCharge);
201+
Double actualCharge = party.getCoverCharge();
202+
assertThat(actualCharge).isEqualTo(expectedCharge);
203+
}
204+
205+
@Test
206+
void testGetTicketNum() {
207+
Party party =
208+
new Party(
209+
"Everyday People",
210+
"Washington D.C.",
211+
"2025-06-012",
212+
false,
213+
50.0,
214+
0,
215+
Vibe.CHILL,
216+
new String[] {});
217+
int expectedNum = 10;
218+
party.setTicketNumber(expectedNum);
219+
int actualTicketNumber = party.getTicketNumber();
220+
assertThat(actualTicketNumber).isEqualTo(expectedNum);
221+
}
222+
223+
@Test
224+
void testSetTicketNum() {
225+
Party party =
226+
new Party(
227+
"Everyday People",
228+
"Washington D.C.",
229+
"2025-06-012",
230+
false,
231+
50.0,
232+
0,
233+
Vibe.CHILL,
234+
new String[] {});
235+
int expectedNum = 10;
236+
party.setTicketNumber(expectedNum);
237+
int actualTicketNumber = party.getTicketNumber();
238+
assertThat(actualTicketNumber).isEqualTo(expectedNum);
239+
}
240+
241+
@Test
242+
void testGuestList() {
243+
Party party =
244+
new Party(
245+
"Everyday People",
246+
"Washington D.C.",
247+
"2025-06-012",
248+
false,
249+
50.0,
250+
0,
251+
Vibe.CHILL,
252+
new String[] {});
253+
String[] expectedGuestList = {"Meiko", "Ezra", "Bryana", "Justin"};
254+
255+
ArrayList<String> guestList = new ArrayList<>(Arrays.asList(expectedGuestList));
256+
party.setGuestList(guestList);
257+
258+
ArrayList<String> actualGuestList = party.getGuestList();
259+
assertThat(actualGuestList).isEqualTo(new ArrayList<>(Arrays.asList(expectedGuestList)));
260+
}
261+
}

0 commit comments

Comments
 (0)