-
Notifications
You must be signed in to change notification settings - Fork 23
feat: adds classes and unit tests to lesson16 homework #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
439f6a8
feat: adds Party and Vive classes with guest management functionality
enyabuti 64b7062
feat: adds Party and Vibe classes with guest management functionality
enyabuti 4e5de26
feat: refactors Party and PartyException classes; adds unit tests for…
enyabuti b7346d1
feat: refactor Party and PartyException classes; add unit tests for P…
enyabuti fa39905
feat: replace PartyException with PartyCityException; update tests ac…
enyabuti b5fc09e
Update settings.json
enyabuti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
..._16/objects/objects_app/src/main/java/com/codedifferently/lesson16/ezranyabuti/Party.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.codedifferently.lesson16.ezranyabuti; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Party { | ||
|
||
private String name; | ||
private String location; | ||
private String localDate; | ||
private Boolean isPrivate; | ||
private double coverCharge; | ||
private int ticketNumber; | ||
private Vibe vibe; | ||
private ArrayList<String> guestList; | ||
|
||
public Party( | ||
String name, | ||
String location, | ||
String localDate, | ||
Boolean isPrivate, | ||
Double coverCharge, | ||
int ticketNumber, | ||
Vibe vibe, | ||
String[] guestList) { | ||
this.name = name; | ||
this.location = location; | ||
this.isPrivate = isPrivate; | ||
this.coverCharge = coverCharge; | ||
this.ticketNumber = ticketNumber; | ||
this.vibe = vibe; | ||
this.guestList = new ArrayList<>(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getLocation() { | ||
return location; | ||
} | ||
|
||
public void setLocation(String location) { | ||
this.location = location; | ||
} | ||
|
||
public String getLocalDate() { | ||
return localDate; | ||
} | ||
|
||
public void setLocalDate(String localDate) { | ||
this.localDate = localDate; | ||
} | ||
|
||
public Boolean getIsPrivate() { | ||
return isPrivate; | ||
} | ||
|
||
public void setIsPrivate(Boolean isPrivate) { | ||
this.isPrivate = isPrivate; | ||
} | ||
|
||
public double getCoverCharge() { | ||
return coverCharge; | ||
} | ||
|
||
public void setCoverCharge(double coverCharge) { | ||
this.coverCharge = coverCharge; | ||
} | ||
|
||
public int getTicketNumber() { | ||
return ticketNumber; | ||
} | ||
|
||
public void setTicketNumber(int ticketNumber) { | ||
this.ticketNumber = ticketNumber; | ||
} | ||
|
||
public Vibe getVibe() { | ||
return vibe; | ||
} | ||
|
||
public void setVibe(Vibe vibe) { | ||
this.vibe = vibe; | ||
} | ||
|
||
public ArrayList<String> getGuestList() { | ||
ArrayList<String> copy = new ArrayList<>(); | ||
for (String guest : guestList) { | ||
copy.add(guest); | ||
} | ||
return copy; | ||
} | ||
|
||
public void setGuestList(ArrayList<String> guestList) { | ||
this.guestList = guestList; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...bjects_app/src/main/java/com/codedifferently/lesson16/ezranyabuti/PartyCityException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.codedifferently.lesson16.ezranyabuti; | ||
|
||
public class PartyCityException extends Exception { | ||
public PartyCityException(String message) { | ||
super(message); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...n_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/ezranyabuti/Vibe.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.codedifferently.lesson16.ezranyabuti; | ||
|
||
public enum Vibe { | ||
CHILL, | ||
PRIVATE, | ||
ALL_WHITE, | ||
RELAXED_LOUNGE, | ||
COSTUME | ||
} |
15 changes: 15 additions & 0 deletions
15
...bjects_app/src/test/java/com/codedifferently/lesson16/ezranyabuti/PartyExceptionTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.codedifferently.lesson16.ezranyabuti; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class PartyExceptionTest { | ||
@Test | ||
void testConstructor() { | ||
String expectedMessage = "Party is not private"; | ||
PartyCityException exception = new PartyCityException(expectedMessage); | ||
String actualMessage = exception.getMessage(); | ||
assertThat(actualMessage).isEqualTo(expectedMessage); | ||
} | ||
} |
261 changes: 261 additions & 0 deletions
261
...objects/objects_app/src/test/java/com/codedifferently/lesson16/ezranyabuti/PartyTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
package com.codedifferently.lesson16.ezranyabuti; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PartyTest { | ||
|
||
@Test | ||
void testGetName() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String expectedName = "Everyday People"; | ||
party.setName(expectedName); | ||
String actualName = party.getName(); | ||
assertThat(actualName).isEqualTo(expectedName); | ||
} | ||
|
||
@Test | ||
void testGetlocalDate() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String expectedDate = "2025-06-012"; | ||
party.setLocalDate(expectedDate); | ||
String actualDate = party.getLocalDate(); | ||
assertThat(actualDate).isEqualTo(expectedDate); | ||
} | ||
|
||
@Test | ||
void testGetCoverCharge() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
Double expectedCharge = 50.0; | ||
party.setCoverCharge(expectedCharge); | ||
Double actualCharge = party.getCoverCharge(); | ||
assertThat(actualCharge).isEqualTo(expectedCharge); | ||
} | ||
|
||
@Test | ||
void testGetVibe() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
Vibe expectedVibe = Vibe.CHILL; | ||
party.setVibe(expectedVibe); | ||
Vibe actualVibe = party.getVibe(); | ||
assertThat(actualVibe).isEqualTo(expectedVibe); | ||
} | ||
|
||
@Test | ||
void testSetVibe() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
} | ||
|
||
@Test | ||
void testSetName() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String expectedName = "Everyday People"; | ||
party.setName(expectedName); | ||
String actualName = party.getName(); | ||
assertThat(actualName).isEqualTo(expectedName); | ||
} | ||
|
||
@Test | ||
void testSetLocation() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String expectedLocation = "Brooklyn"; | ||
party.setLocation(expectedLocation); | ||
String actualLocation = party.getLocation(); | ||
assertThat(actualLocation).isEqualTo(expectedLocation); | ||
} | ||
|
||
@Test | ||
void testGetLocation() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String expectedLocation = "Brooklyn"; | ||
party.setLocation(expectedLocation); | ||
String actualLocation = party.getLocation(); | ||
assertThat(actualLocation).isEqualTo(expectedLocation); | ||
} | ||
|
||
@Test | ||
void testGetPrivate() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
Boolean expectedPrivate = false; | ||
party.setIsPrivate(expectedPrivate); | ||
Boolean actualPrivate = party.getIsPrivate(); | ||
assertThat(actualPrivate).isEqualTo(expectedPrivate); | ||
} | ||
|
||
@Test | ||
void testSetPrivate() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
Boolean expectedPrivate = true; | ||
party.setIsPrivate(expectedPrivate); | ||
Boolean actualPrivate = party.getIsPrivate(); | ||
assertThat(actualPrivate).isEqualTo(expectedPrivate); | ||
} | ||
|
||
@Test | ||
void testCoverCharge() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
Double expectedCharge = 50.0; | ||
party.setCoverCharge(expectedCharge); | ||
Double actualCharge = party.getCoverCharge(); | ||
assertThat(actualCharge).isEqualTo(expectedCharge); | ||
} | ||
|
||
@Test | ||
void testGetTicketNum() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
int expectedNum = 10; | ||
party.setTicketNumber(expectedNum); | ||
int actualTicketNumber = party.getTicketNumber(); | ||
assertThat(actualTicketNumber).isEqualTo(expectedNum); | ||
} | ||
|
||
@Test | ||
void testSetTicketNum() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
int expectedNum = 10; | ||
party.setTicketNumber(expectedNum); | ||
int actualTicketNumber = party.getTicketNumber(); | ||
assertThat(actualTicketNumber).isEqualTo(expectedNum); | ||
} | ||
|
||
@Test | ||
void testGuestList() { | ||
Party party = | ||
new Party( | ||
"Everyday People", | ||
"Washington D.C.", | ||
"2025-06-012", | ||
false, | ||
50.0, | ||
0, | ||
Vibe.CHILL, | ||
new String[] {}); | ||
String[] expectedGuestList = {"Meiko", "Ezra", "Bryana", "Justin"}; | ||
|
||
ArrayList<String> guestList = new ArrayList<>(Arrays.asList(expectedGuestList)); | ||
party.setGuestList(guestList); | ||
|
||
ArrayList<String> actualGuestList = party.getGuestList(); | ||
assertThat(actualGuestList).isEqualTo(new ArrayList<>(Arrays.asList(expectedGuestList))); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.