From c0fb9025215a43e92cce9a54456acf1388ef5152 Mon Sep 17 00:00:00 2001 From: bryanasb251 Date: Thu, 10 Apr 2025 21:09:41 +0000 Subject: [PATCH 1/4] feat: add hip hop artist classes and corresponding tests --- .../lesson16/hiphopArtist/DMX.java | 33 ++++ .../lesson16/hiphopArtist/Eminem.java | 33 ++++ .../lesson16/hiphopArtist/HipHopArtist.java | 142 ++++++++++++++++++ .../lesson16/hiphopArtist/JayZ.java | 34 +++++ .../lesson16/hiphopArtist/KanyeWest.java | 34 +++++ .../lesson16/hiphopArtist/NipseyHussle.java | 33 ++++ .../lesson16/hiphopArtistTest/DMXtest.java | 36 +++++ .../lesson16/hiphopArtistTest/Eminemtest.java | 36 +++++ .../lesson16/hiphopArtistTest/JayZtest.java | 37 +++++ .../hiphopArtistTest/KanyeWestTest.java | 36 +++++ .../hiphopArtistTest/NipseyHussletest.java | 36 +++++ 11 files changed, 490 insertions(+) create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java create mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java new file mode 100644 index 000000000..a3efc63b5 --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java @@ -0,0 +1,33 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class DMX { + public static void main(String[] args) { + ArrayList dmxAlbums = new ArrayList<>(); + dmxAlbums.add("It's Dark and Hell Is Hot"); + dmxAlbums.add("Flesh of My Flesh, Blood of My Blood"); + dmxAlbums.add("And Then There Was X"); + dmxAlbums.add("The Great Depression"); + dmxAlbums.add("Grand Champ"); + + var dmx = + new HipHopArtist(false, "DMX", 1998, 10000000, dmxAlbums, HipHopArtist.Genre.GANGSTA_RAP); + + System.out.println(dmx.getBio()); + System.out.println(dmx.checkLegendStatus()); + + dmx.addAlbum("The Definition of X: Pick of the Litter"); + + try { + dmx.listAlbums(); + } catch (NoAlbumsException e) { + System.out.println("ERROR: " + e.getMessage()); + } + + System.out.println(dmx); + + dmx.setNetWorth(12000000); + System.out.println("Updated net worth: $" + dmx.getNetWorth()); + } +} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java new file mode 100644 index 000000000..dff03a58f --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java @@ -0,0 +1,33 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class Eminem { + public static void main(String[] args) { + ArrayList EminemAlbums = new ArrayList<>(); + EminemAlbums.add("The Slim Shady LP"); + EminemAlbums.add("The Marshall Mathers LP"); + EminemAlbums.add("The Eminem Show"); + EminemAlbums.add("Encore"); + EminemAlbums.add("Relapse"); + + for (String album : EminemAlbums) { + System.out.println(album); + } + var eminem = + new HipHopArtist(true, "Eminem", 1999, 230000000, EminemAlbums, HipHopArtist.Genre.RAP); + System.out.println(eminem.getBio()); + System.out.println(eminem.checkLegendStatus()); + + eminem.addAlbum("The Marshall Mathers LP 2"); + + try { + eminem.listAlbums(); + } catch (NoAlbumsException e) { + System.out.println("ERROR: " + e.getMessage()); + } + System.out.println(eminem); + eminem.setNetWorth(250000000); + System.out.println("Updated net worth: $" + eminem.getNetWorth()); + } +} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java new file mode 100644 index 000000000..02e73a6e4 --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java @@ -0,0 +1,142 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class HipHopArtist { + private boolean isAlive; + private String stageName; + private int debutYear; + private double netWorth; + private ArrayList albums; + private Genre genre; + + public HipHopArtist( + boolean isAlive, + String stageName, + int debutYear, + double netWorth, + ArrayList albums, + Genre genre) { + this.isAlive = isAlive; + this.stageName = stageName; + this.debutYear = debutYear; + this.netWorth = netWorth; + this.albums = albums; + this.genre = genre; + } + + public String checkLegendStatus() { + return debutYear <= 2000 + ? stageName + " is a legend in the game." + : stageName + " is a modern star."; + } + + public void addAlbum(String album) { + albums.add(album); + System.out.println(album + " was added to " + stageName + "'s discography."); + } + + public void listAlbums() throws NoAlbumsException { + if (albums.isEmpty()) { + throw new NoAlbumsException(stageName + " has no albums listed."); + } + System.out.println("Albums by " + stageName + ":"); + for (String album : albums) { + System.out.println("- " + album); + } + } + + public String getBio() { + return stageName + + " (" + + genre + + ") debuted in " + + debutYear + + ", is " + + (isAlive ? "alive" : "deceased") + + ", and has a net worth of $" + + netWorth + + "."; + } + + public boolean isAlive() { + return isAlive; + } + + public void setAlive(boolean alive) { + isAlive = alive; + } + + public String getStageName() { + return stageName; + } + + public void setStageName(String stageName) { + this.stageName = stageName; + } + + public int getDebutYear() { + return debutYear; + } + + public void setDebutYear(int debutYear) { + this.debutYear = debutYear; + } + + public double getNetWorth() { + return netWorth; + } + + public void setNetWorth(double netWorth) { + this.netWorth = netWorth; + } + + public ArrayList getAlbums() { + return albums; + } + + public void setAlbums(ArrayList albums) { + this.albums = albums; + } + + public Genre getGenre() { + return genre; + } + + public void setGenre(Genre genre) { + this.genre = genre; + } + + public enum Genre { + RAP, + GANGSTA_RAP, + OLD_SCHOOL, + TRAP, + DRILL, + } + + @Override + public String toString() { + return "HipHopArtist{" + + "isAlive=" + + isAlive + + ", stageName='" + + stageName + + '\'' + + ", debutYear=" + + debutYear + + ", netWorth=" + + netWorth + + ", albums=" + + albums + + ", genre=" + + genre + + '}'; + } +} + +class NoAlbumsException extends Exception { + public NoAlbumsException(String message) { + super(message); + } +} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java new file mode 100644 index 000000000..d79863ab3 --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java @@ -0,0 +1,34 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class JayZ { + + public static void main(String[] args) { + ArrayList jayZAlbums = new ArrayList<>(); + jayZAlbums.add("Reasonable Doubt"); + jayZAlbums.add("The Blueprint"); + jayZAlbums.add("The Black Album"); + jayZAlbums.add("4:44"); + jayZAlbums.add("Watch the Throne"); + + var jayZ = + new HipHopArtist(true, "Jay-Z", 1996, 1500000000, jayZAlbums, HipHopArtist.Genre.RAP); + + System.out.println(jayZ.getBio()); + System.out.println(jayZ.checkLegendStatus()); + + jayZ.addAlbum("Kingdom Come"); + + try { + jayZ.listAlbums(); + } catch (NoAlbumsException e) { + System.out.println("ERROR: " + e.getMessage()); + } + + System.out.println(jayZ); + + jayZ.setNetWorth(1600000000); + System.out.println("Updated net worth: $" + jayZ.getNetWorth()); + } +} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java new file mode 100644 index 000000000..e5b125f52 --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java @@ -0,0 +1,34 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class KanyeWest { + + public static void main(String[] args) { + ArrayList kanyeAlbums = new ArrayList<>(); + kanyeAlbums.add("The College Dropout"); + kanyeAlbums.add("Late Registration"); + kanyeAlbums.add("Graduation"); + kanyeAlbums.add("My Beautiful Dark Twisted Fantasy"); + kanyeAlbums.add("Yeezus"); + + var kanye = + new HipHopArtist(true, "Kanye West", 2004, 400000000, kanyeAlbums, HipHopArtist.Genre.RAP); + + System.out.println(kanye.getBio()); + System.out.println(kanye.checkLegendStatus()); + + kanye.addAlbum("Donda"); + + try { + kanye.listAlbums(); + } catch (NoAlbumsException e) { + System.out.println("ERROR: " + e.getMessage()); + } + + System.out.println(kanye); + + kanye.setNetWorth(500000000); + System.out.println("Updated net worth: $" + kanye.getNetWorth()); + } +} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java new file mode 100644 index 000000000..7dfbe232f --- /dev/null +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java @@ -0,0 +1,33 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import java.util.ArrayList; + +public class NipseyHussle { + public static void main(String[] args) { + ArrayList nipseyAlbums = new ArrayList<>(); + nipseyAlbums.add("South Central State of Mind"); + nipseyAlbums.add("The Marathon"); + nipseyAlbums.add("Crenshaw"); + nipseyAlbums.add("Victory Lap"); + + for (String album : nipseyAlbums) { + System.out.println(album); + } + var nipsey = + new HipHopArtist( + true, "Nipsey Hussle", 2005, 8000000, nipseyAlbums, HipHopArtist.Genre.GANGSTA_RAP); + System.out.println(nipsey.getBio()); + System.out.println(nipsey.checkLegendStatus()); + + nipsey.addAlbum("The Marathon Continues"); + + try { + nipsey.listAlbums(); + } catch (NoAlbumsException e) { + System.out.println("ERROR: " + e.getMessage()); + } + System.out.println(nipsey); + nipsey.setNetWorth(10000000); + System.out.println("Updated net worth: $" + nipsey.getNetWorth()); + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java new file mode 100644 index 000000000..9d17e6c8e --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java @@ -0,0 +1,36 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import com.codedifferently.lesson16.hiphopArtist.DMX; +import org.junit.jupiter.api.Test; + +public class DMXtest { + @Test + public void testDMX() { + DMX.main(new String[0]); // Call the main method of DMX class + } + + @Test + public void testDMXCheckLegendStatus() { + DMX.main(new String[0]); // Call the main method of DMX class + } + + @Test + public void testDMXAddAlbum() { + DMX.main(new String[0]); // Call the main method of DMX class + } + + @Test + public void testDMXListAlbums() { + DMX.main(new String[0]); // Call the main method of DMX class + } + + @Test + public void testDMXGetBio() { + DMX.main(new String[0]); // Call the main method of DMX class + } + + @Test + public void testDMXGetNetWorth() { + DMX.main(new String[0]); // Call the main method of DMX class + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java new file mode 100644 index 000000000..f8bc13755 --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java @@ -0,0 +1,36 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import com.codedifferently.lesson16.hiphopArtist.Eminem; +import org.junit.jupiter.api.Test; + +public class Eminemtest { + @Test + public void testEminem() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } + + @Test + public void testEminemCheckLegendStatus() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } + + @Test + public void testEminemAddAlbum() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } + + @Test + public void testEminemListAlbums() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } + + @Test + public void testEminemGetBio() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } + + @Test + public void testEminemGetNetWorth() { + Eminem.main(new String[0]); // Call the main method of Eminem class + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java new file mode 100644 index 000000000..a29fc6223 --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java @@ -0,0 +1,37 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import com.codedifferently.lesson16.hiphopArtist.JayZ; +import org.junit.jupiter.api.Test; + +public class JayZtest { + + @Test + public void testJayZ() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } + + @Test + public void testJayZCheckLegendStatus() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } + + @Test + public void testJayZAddAlbum() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } + + @Test + public void testJayZListAlbums() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } + + @Test + public void testJayZGetBio() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } + + @Test + public void testJayZGetNetWorth() { + JayZ.main(new String[0]); // Call the main method of JayZ class + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java new file mode 100644 index 000000000..0128e029a --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java @@ -0,0 +1,36 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import com.codedifferently.lesson16.hiphopArtist.KanyeWest; +import org.junit.jupiter.api.Test; + +public class KanyeWestTest { + @Test + public void testKanyeWest() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } + + @Test + public void testKanyeWestCheckLegendStatus() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } + + @Test + public void testKanyeWestAddAlbum() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } + + @Test + public void testKanyeWestListAlbums() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } + + @Test + public void testKanyeWestGetBio() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } + + @Test + public void testKanyeWestGetNetWorth() { + KanyeWest.main(new String[0]); // Call the main method of KanyeWest class + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java new file mode 100644 index 000000000..6a9de3e5e --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java @@ -0,0 +1,36 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import com.codedifferently.lesson16.hiphopArtist.NipseyHussle; +import org.junit.jupiter.api.Test; + +public class NipseyHussletest { + @Test + public void testNipseyHussle() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } + + @Test + public void testNipseyHussleCheckLegendStatus() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } + + @Test + public void testNipseyHussleAddAlbum() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } + + @Test + public void testNipseyHussleListAlbums() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } + + @Test + public void testNipseyHussleGetBio() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } + + @Test + public void testNipseyHussleGetNetWorth() { + NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class + } +} From 9aa5210e61922fc8bfc4bc478e16d73e262b294e Mon Sep 17 00:00:00 2001 From: bryanasb251 Date: Sat, 12 Apr 2025 23:17:12 +0000 Subject: [PATCH 2/4] feat: refactor HipHopArtist class and remove unused artist classes and tests --- .../lesson16/hiphopArtist/DMX.java | 33 ---- .../lesson16/hiphopArtist/Eminem.java | 33 ---- .../lesson16/hiphopArtist/HipHopArtist.java | 3 +- .../lesson16/hiphopArtist/JayZ.java | 34 ---- .../lesson16/hiphopArtist/KanyeWest.java | 34 ---- .../lesson16/hiphopArtist/NipseyHussle.java | 33 ---- .../lesson16/hiphopArtistTest/DMXtest.java | 36 ---- .../lesson16/hiphopArtistTest/Eminemtest.java | 36 ---- .../hiphopArtistTest/HipHopArtistTest.java | 163 ++++++++++++++++++ .../lesson16/hiphopArtistTest/JayZtest.java | 37 ---- .../hiphopArtistTest/KanyeWestTest.java | 36 ---- .../hiphopArtistTest/NipseyHussletest.java | 36 ---- 12 files changed, 165 insertions(+), 349 deletions(-) delete mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java delete mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java delete mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java delete mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java delete mode 100644 lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java deleted file mode 100644 index a3efc63b5..000000000 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/DMX.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtist; - -import java.util.ArrayList; - -public class DMX { - public static void main(String[] args) { - ArrayList dmxAlbums = new ArrayList<>(); - dmxAlbums.add("It's Dark and Hell Is Hot"); - dmxAlbums.add("Flesh of My Flesh, Blood of My Blood"); - dmxAlbums.add("And Then There Was X"); - dmxAlbums.add("The Great Depression"); - dmxAlbums.add("Grand Champ"); - - var dmx = - new HipHopArtist(false, "DMX", 1998, 10000000, dmxAlbums, HipHopArtist.Genre.GANGSTA_RAP); - - System.out.println(dmx.getBio()); - System.out.println(dmx.checkLegendStatus()); - - dmx.addAlbum("The Definition of X: Pick of the Litter"); - - try { - dmx.listAlbums(); - } catch (NoAlbumsException e) { - System.out.println("ERROR: " + e.getMessage()); - } - - System.out.println(dmx); - - dmx.setNetWorth(12000000); - System.out.println("Updated net worth: $" + dmx.getNetWorth()); - } -} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java deleted file mode 100644 index dff03a58f..000000000 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/Eminem.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtist; - -import java.util.ArrayList; - -public class Eminem { - public static void main(String[] args) { - ArrayList EminemAlbums = new ArrayList<>(); - EminemAlbums.add("The Slim Shady LP"); - EminemAlbums.add("The Marshall Mathers LP"); - EminemAlbums.add("The Eminem Show"); - EminemAlbums.add("Encore"); - EminemAlbums.add("Relapse"); - - for (String album : EminemAlbums) { - System.out.println(album); - } - var eminem = - new HipHopArtist(true, "Eminem", 1999, 230000000, EminemAlbums, HipHopArtist.Genre.RAP); - System.out.println(eminem.getBio()); - System.out.println(eminem.checkLegendStatus()); - - eminem.addAlbum("The Marshall Mathers LP 2"); - - try { - eminem.listAlbums(); - } catch (NoAlbumsException e) { - System.out.println("ERROR: " + e.getMessage()); - } - System.out.println(eminem); - eminem.setNetWorth(250000000); - System.out.println("Updated net worth: $" + eminem.getNetWorth()); - } -} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java index 02e73a6e4..d04a1e599 100644 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java +++ b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtist.java @@ -36,7 +36,7 @@ public void addAlbum(String album) { System.out.println(album + " was added to " + stageName + "'s discography."); } - public void listAlbums() throws NoAlbumsException { + public String listAlbums() throws NoAlbumsException { if (albums.isEmpty()) { throw new NoAlbumsException(stageName + " has no albums listed."); } @@ -44,6 +44,7 @@ public void listAlbums() throws NoAlbumsException { for (String album : albums) { System.out.println("- " + album); } + return stageName; } public String getBio() { diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java deleted file mode 100644 index d79863ab3..000000000 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/JayZ.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtist; - -import java.util.ArrayList; - -public class JayZ { - - public static void main(String[] args) { - ArrayList jayZAlbums = new ArrayList<>(); - jayZAlbums.add("Reasonable Doubt"); - jayZAlbums.add("The Blueprint"); - jayZAlbums.add("The Black Album"); - jayZAlbums.add("4:44"); - jayZAlbums.add("Watch the Throne"); - - var jayZ = - new HipHopArtist(true, "Jay-Z", 1996, 1500000000, jayZAlbums, HipHopArtist.Genre.RAP); - - System.out.println(jayZ.getBio()); - System.out.println(jayZ.checkLegendStatus()); - - jayZ.addAlbum("Kingdom Come"); - - try { - jayZ.listAlbums(); - } catch (NoAlbumsException e) { - System.out.println("ERROR: " + e.getMessage()); - } - - System.out.println(jayZ); - - jayZ.setNetWorth(1600000000); - System.out.println("Updated net worth: $" + jayZ.getNetWorth()); - } -} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java deleted file mode 100644 index e5b125f52..000000000 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/KanyeWest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtist; - -import java.util.ArrayList; - -public class KanyeWest { - - public static void main(String[] args) { - ArrayList kanyeAlbums = new ArrayList<>(); - kanyeAlbums.add("The College Dropout"); - kanyeAlbums.add("Late Registration"); - kanyeAlbums.add("Graduation"); - kanyeAlbums.add("My Beautiful Dark Twisted Fantasy"); - kanyeAlbums.add("Yeezus"); - - var kanye = - new HipHopArtist(true, "Kanye West", 2004, 400000000, kanyeAlbums, HipHopArtist.Genre.RAP); - - System.out.println(kanye.getBio()); - System.out.println(kanye.checkLegendStatus()); - - kanye.addAlbum("Donda"); - - try { - kanye.listAlbums(); - } catch (NoAlbumsException e) { - System.out.println("ERROR: " + e.getMessage()); - } - - System.out.println(kanye); - - kanye.setNetWorth(500000000); - System.out.println("Updated net worth: $" + kanye.getNetWorth()); - } -} diff --git a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java b/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java deleted file mode 100644 index 7dfbe232f..000000000 --- a/lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/hiphopArtist/NipseyHussle.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtist; - -import java.util.ArrayList; - -public class NipseyHussle { - public static void main(String[] args) { - ArrayList nipseyAlbums = new ArrayList<>(); - nipseyAlbums.add("South Central State of Mind"); - nipseyAlbums.add("The Marathon"); - nipseyAlbums.add("Crenshaw"); - nipseyAlbums.add("Victory Lap"); - - for (String album : nipseyAlbums) { - System.out.println(album); - } - var nipsey = - new HipHopArtist( - true, "Nipsey Hussle", 2005, 8000000, nipseyAlbums, HipHopArtist.Genre.GANGSTA_RAP); - System.out.println(nipsey.getBio()); - System.out.println(nipsey.checkLegendStatus()); - - nipsey.addAlbum("The Marathon Continues"); - - try { - nipsey.listAlbums(); - } catch (NoAlbumsException e) { - System.out.println("ERROR: " + e.getMessage()); - } - System.out.println(nipsey); - nipsey.setNetWorth(10000000); - System.out.println("Updated net worth: $" + nipsey.getNetWorth()); - } -} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java deleted file mode 100644 index 9d17e6c8e..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/DMXtest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import com.codedifferently.lesson16.hiphopArtist.DMX; -import org.junit.jupiter.api.Test; - -public class DMXtest { - @Test - public void testDMX() { - DMX.main(new String[0]); // Call the main method of DMX class - } - - @Test - public void testDMXCheckLegendStatus() { - DMX.main(new String[0]); // Call the main method of DMX class - } - - @Test - public void testDMXAddAlbum() { - DMX.main(new String[0]); // Call the main method of DMX class - } - - @Test - public void testDMXListAlbums() { - DMX.main(new String[0]); // Call the main method of DMX class - } - - @Test - public void testDMXGetBio() { - DMX.main(new String[0]); // Call the main method of DMX class - } - - @Test - public void testDMXGetNetWorth() { - DMX.main(new String[0]); // Call the main method of DMX class - } -} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java deleted file mode 100644 index f8bc13755..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/Eminemtest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import com.codedifferently.lesson16.hiphopArtist.Eminem; -import org.junit.jupiter.api.Test; - -public class Eminemtest { - @Test - public void testEminem() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } - - @Test - public void testEminemCheckLegendStatus() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } - - @Test - public void testEminemAddAlbum() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } - - @Test - public void testEminemListAlbums() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } - - @Test - public void testEminemGetBio() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } - - @Test - public void testEminemGetNetWorth() { - Eminem.main(new String[0]); // Call the main method of Eminem class - } -} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java new file mode 100644 index 000000000..6ce55592b --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java @@ -0,0 +1,163 @@ +package com.codedifferently.lesson16.hiphopArtistTest; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.codedifferently.lesson16.hiphopArtist.HipHopArtist; +import com.codedifferently.lesson16.hiphopArtist.HipHopArtist.Genre; +import java.util.ArrayList; +import org.junit.jupiter.api.Test; + +public class HipHopArtistTest { + + @Test + public void testCheckLegendStatus() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Check legend status + String expected = "Kendrick Lamar is a modern star."; + String actual = artist.checkLegendStatus(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testAddAlbum() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Add an album + artist.addAlbum("good kid, m.A.A.d city"); + + // Check if the album was added + assertTrue(artist.getAlbums().contains("good kid, m.A.A.d city")); + } + + @Test + public void testIsAlive() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Check if the artist is alive + boolean expected = true; + boolean actual = artist.isAlive(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetStageName() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get stage name + String expected = "Kendrick Lamar"; + String actual = artist.getStageName(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetAlive() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set alive status to false + artist.setAlive(false); + + // Check if the artist is alive + boolean expected = false; + boolean actual = artist.isAlive(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetStageName() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set stage name + artist.setStageName("K.Dot"); + + // Get stage name + String expected = "K.Dot"; + String actual = artist.getStageName(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetDebutYear() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get debut year + int expected = 2012; + int actual = artist.getDebutYear(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetDebutYear() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set debut year + artist.setDebutYear(2011); + + // Get debut year + int expected = 2011; + int actual = artist.getDebutYear(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetNetWorth() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get net worth + double expected = 75_000_000; + double actual = artist.getNetWorth(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetNetWorth() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set net worth + artist.setNetWorth(80_000_000); + + // Get net worth + double expected = 80_000_000; + double actual = artist.getNetWorth(); + + // Assert the result + assertEquals(expected, actual); + } +} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java deleted file mode 100644 index a29fc6223..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/JayZtest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import com.codedifferently.lesson16.hiphopArtist.JayZ; -import org.junit.jupiter.api.Test; - -public class JayZtest { - - @Test - public void testJayZ() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } - - @Test - public void testJayZCheckLegendStatus() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } - - @Test - public void testJayZAddAlbum() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } - - @Test - public void testJayZListAlbums() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } - - @Test - public void testJayZGetBio() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } - - @Test - public void testJayZGetNetWorth() { - JayZ.main(new String[0]); // Call the main method of JayZ class - } -} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java deleted file mode 100644 index 0128e029a..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/KanyeWestTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import com.codedifferently.lesson16.hiphopArtist.KanyeWest; -import org.junit.jupiter.api.Test; - -public class KanyeWestTest { - @Test - public void testKanyeWest() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } - - @Test - public void testKanyeWestCheckLegendStatus() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } - - @Test - public void testKanyeWestAddAlbum() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } - - @Test - public void testKanyeWestListAlbums() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } - - @Test - public void testKanyeWestGetBio() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } - - @Test - public void testKanyeWestGetNetWorth() { - KanyeWest.main(new String[0]); // Call the main method of KanyeWest class - } -} diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java deleted file mode 100644 index 6a9de3e5e..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/NipseyHussletest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import com.codedifferently.lesson16.hiphopArtist.NipseyHussle; -import org.junit.jupiter.api.Test; - -public class NipseyHussletest { - @Test - public void testNipseyHussle() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } - - @Test - public void testNipseyHussleCheckLegendStatus() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } - - @Test - public void testNipseyHussleAddAlbum() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } - - @Test - public void testNipseyHussleListAlbums() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } - - @Test - public void testNipseyHussleGetBio() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } - - @Test - public void testNipseyHussleGetNetWorth() { - NipseyHussle.main(new String[0]); // Call the main method of NipseyHussle class - } -} From d2f26bb24915b84de5797a1922f9215ce048edff Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Wed, 23 Apr 2025 23:29:20 +0000 Subject: [PATCH 3/4] chore: corrects namespace for test Signed-off-by: Anthony D. Mays --- .../hiphopArtistTest/HipHopArtistTest.java | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java deleted file mode 100644 index 6ce55592b..000000000 --- a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtistTest/HipHopArtistTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.codedifferently.lesson16.hiphopArtistTest; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.codedifferently.lesson16.hiphopArtist.HipHopArtist; -import com.codedifferently.lesson16.hiphopArtist.HipHopArtist.Genre; -import java.util.ArrayList; -import org.junit.jupiter.api.Test; - -public class HipHopArtistTest { - - @Test - public void testCheckLegendStatus() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Check legend status - String expected = "Kendrick Lamar is a modern star."; - String actual = artist.checkLegendStatus(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testAddAlbum() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Add an album - artist.addAlbum("good kid, m.A.A.d city"); - - // Check if the album was added - assertTrue(artist.getAlbums().contains("good kid, m.A.A.d city")); - } - - @Test - public void testIsAlive() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Check if the artist is alive - boolean expected = true; - boolean actual = artist.isAlive(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testGetStageName() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Get stage name - String expected = "Kendrick Lamar"; - String actual = artist.getStageName(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testSetAlive() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Set alive status to false - artist.setAlive(false); - - // Check if the artist is alive - boolean expected = false; - boolean actual = artist.isAlive(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testSetStageName() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Set stage name - artist.setStageName("K.Dot"); - - // Get stage name - String expected = "K.Dot"; - String actual = artist.getStageName(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testGetDebutYear() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Get debut year - int expected = 2012; - int actual = artist.getDebutYear(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testSetDebutYear() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Set debut year - artist.setDebutYear(2011); - - // Get debut year - int expected = 2011; - int actual = artist.getDebutYear(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testGetNetWorth() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Get net worth - double expected = 75_000_000; - double actual = artist.getNetWorth(); - - // Assert the result - assertEquals(expected, actual); - } - - @Test - public void testSetNetWorth() { - // Create a HipHopArtist object - HipHopArtist artist = - new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); - - // Set net worth - artist.setNetWorth(80_000_000); - - // Get net worth - double expected = 80_000_000; - double actual = artist.getNetWorth(); - - // Assert the result - assertEquals(expected, actual); - } -} From 1094fd8d5bfc6f4e54f77d7bed8b7baf0c345343 Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Wed, 23 Apr 2025 23:29:32 +0000 Subject: [PATCH 4/4] chore: corrects namespace for test Signed-off-by: Anthony D. Mays --- .../hiphopArtist/HipHopArtistTest.java | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtistTest.java diff --git a/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtistTest.java b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtistTest.java new file mode 100644 index 000000000..cbc5524d2 --- /dev/null +++ b/lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/hiphopArtist/HipHopArtistTest.java @@ -0,0 +1,162 @@ +package com.codedifferently.lesson16.hiphopArtist; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.codedifferently.lesson16.hiphopArtist.HipHopArtist.Genre; +import java.util.ArrayList; +import org.junit.jupiter.api.Test; + +public class HipHopArtistTest { + + @Test + public void testCheckLegendStatus() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Check legend status + String expected = "Kendrick Lamar is a modern star."; + String actual = artist.checkLegendStatus(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testAddAlbum() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Add an album + artist.addAlbum("good kid, m.A.A.d city"); + + // Check if the album was added + assertTrue(artist.getAlbums().contains("good kid, m.A.A.d city")); + } + + @Test + public void testIsAlive() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Check if the artist is alive + boolean expected = true; + boolean actual = artist.isAlive(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetStageName() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get stage name + String expected = "Kendrick Lamar"; + String actual = artist.getStageName(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetAlive() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set alive status to false + artist.setAlive(false); + + // Check if the artist is alive + boolean expected = false; + boolean actual = artist.isAlive(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetStageName() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set stage name + artist.setStageName("K.Dot"); + + // Get stage name + String expected = "K.Dot"; + String actual = artist.getStageName(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetDebutYear() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get debut year + int expected = 2012; + int actual = artist.getDebutYear(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetDebutYear() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set debut year + artist.setDebutYear(2011); + + // Get debut year + int expected = 2011; + int actual = artist.getDebutYear(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testGetNetWorth() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Get net worth + double expected = 75_000_000; + double actual = artist.getNetWorth(); + + // Assert the result + assertEquals(expected, actual); + } + + @Test + public void testSetNetWorth() { + // Create a HipHopArtist object + HipHopArtist artist = + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); + + // Set net worth + artist.setNetWorth(80_000_000); + + // Get net worth + double expected = 80_000_000; + double actual = artist.getNetWorth(); + + // Assert the result + assertEquals(expected, actual); + } +}