Skip to content

Commit 439f6a8

Browse files
committed
feat: adds Party and Vive classes with guest management functionality
1 parent faa4f80 commit 439f6a8

File tree

7 files changed

+157
-15
lines changed

7 files changed

+157
-15
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit dbd529664ed17a53d1974c0c05bcc4dbfbd8a86e
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 void partyClass(
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+
51+
52+
public Boolean getIsPrivate() {
53+
return isPrivate;
54+
}
55+
56+
public void setIsPrivate(Boolean isPrivate) {
57+
this.isPrivate = isPrivate;
58+
}
59+
60+
public ArrayList<String> getGuestList() {
61+
ArrayList<String> copy = new ArrayList<>();
62+
for (String guest : guestList) {
63+
copy.add(guest);
64+
}
65+
return copy;
66+
}
67+
68+
public void setGuestList(ArrayList<String> guestList) {
69+
this.guestList = guestList;
70+
}
71+
72+
public void addGuest(String guest) throws partyException {
73+
if (guestList.size() < ticketNumber) {
74+
guestList.add(guest);
75+
} else {
76+
throw new partyException("Party is full");
77+
}
78+
}
79+
}
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,7 @@
1+
package com.codedifferently.lesson16.ezranyabuti;
2+
3+
public class partyException extends Exception {
4+
public partyException(String message) {
5+
super(message);
6+
}
7+
}

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/Lesson16Test.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package test.java.com.codedifferently.lesson16.ezranyabutitest;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
import com.codedifferently.lesson16.ezranyabuti.Party;
11+
12+
public class PartyTest {
13+
14+
@Test
15+
void testGetName() {
16+
Party party = new Party();
17+
String expectedName = "Everyday People";
18+
19+
party.setName(expectedName);
20+
String actualName = party.getName();
21+
assertThat(actualName).isEqualTo(expectedName);
22+
}
23+
24+
@Test
25+
void testGetLocation() {
26+
Party party = new Party();
27+
String expectedLocation = "Brooklyn";
28+
party.setLocation(expectedLocation);
29+
String actualLocation = party.getLocation();
30+
assertThat(actualLocation).isEqualTo(expectedLocation);
31+
}
32+
33+
@Test
34+
void testGuestList() {
35+
Party party = new Party();
36+
String[] expectedGuestList = {"Meiko", "Ezra", "Bryana", "Justin"};
37+
38+
ArrayList<String> guestList = new ArrayList<>(Arrays.asList(expectedGuestList));
39+
party.setGuestList(guestList);
40+
41+
ArrayList<String> actualGuestList = party.getGuestList();
42+
assertThat(actualGuestList).isEqualTo(new ArrayList<>(Arrays.asList(expectedGuestList)));
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package test.java.com.codedifferently.lesson16.ezranyabutitest;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import com.codedifferently.lesson16.ezranyabuti.partyException;
6+
import org.junit.jupiter.api.Test;
7+
8+
public class partyExceptionTest {
9+
// Test for the constructor
10+
@Test
11+
void testConstructor() {
12+
String expectedMessage = "Party is not private";
13+
partyException exception = new partyException(expectedMessage);
14+
String actualMessage = exception.getMessage();
15+
assertThat(actualMessage).isEqualTo(expectedMessage);
16+
}
17+
}

0 commit comments

Comments
 (0)