Skip to content

Commit

Permalink
Merge pull request #62 from emmaroche/final-tweaks
Browse files Browse the repository at this point in the history
Make final tweaks to code
  • Loading branch information
emmaroche authored Dec 6, 2022
2 parents 2f1b002 + 6aa965e commit bef073a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun welcomeMenu() {
fun welcomeScreen(): Int {

// code reference for adding colour to improve UI: https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#rich-text
// code reference for the menu titles made with ASCII to improve UI: https://patorjk.com/software/taag/#p=display&f=Graceful&t=Youtuber%20app%20menu
// reference for the menu titles made with ASCII to improve UI: https://patorjk.com/software/taag/#p=display&f=Graceful&t=Youtuber%20app%20menu

// displays the colour
val red = "\u001b[31m"
Expand Down Expand Up @@ -589,6 +589,8 @@ fun searchVideosByCategory() {
*/
fun info() {

// reference for the generated ASCII image of the YouTube logo to improve the UI: https://manytools.org/hacker-tools/convert-images-to-ascii-art/go/

// displays the colour
val brightRed = "\u001b[31;1m"
// resets colour and decoration back to what it previously was
Expand Down Expand Up @@ -636,7 +638,7 @@ fun info() {
// EXIT APP
// ------------------------------------
/**
* This function is for exitings the app.
* This function is for exiting the app.
*/
fun exitApp() {
println("\n Exiting app ... Thank you for using! :)")
Expand Down
31 changes: 27 additions & 4 deletions src/main/kotlin/controllers/YoutuberAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class YoutuberAPI(serializerType: Serializer) {
else {
val listOfSubs = formatListString(youtubers.filter { youtubers -> youtubers.youtuberSubscribers >= sub })
if (listOfSubs == "") "\n No YouTubers with $sub or more subscribers found\n"
else "\n ${numberOfYoutubersBySubCount(sub)} Youtubers(s) with $sub or more subscribers\n: $listOfSubs"
else "\n $listOfSubs"
}

// ----------------------------------------------
Expand All @@ -167,13 +167,20 @@ class YoutuberAPI(serializerType: Serializer) {
* This function is for listing the watched Videos in an arraylist by title.
*/
fun listWatchedVideos(): String =

if (numberOfYoutubers() == 0) "\n No videos stored"
else {
// displays the colour
val red = "\u001b[31m"
// displays the decoration
val bold = "\u001b[1m"
// resets colour and decoration back to what it previously was
val reset = "\u001b[0m"
var listOfWatched = " "
for (youtube in youtubers) {
for (video in youtube.videos) {
if (video.markVideoAsWatched) {
listOfWatched += youtube.youtuberChannelName + ": " + video.videoTitle + ": " + video.watchedStatus + "\n"
listOfWatched += "$red$bold" + video.videoTitle + "$reset: " + video.watchedStatus + "\n"
}
}
}
Expand All @@ -187,13 +194,21 @@ class YoutuberAPI(serializerType: Serializer) {
* This function is for searching for a Video in an arraylist by title.
*/
fun searchVideoByTitle(searchString: String): String {
// displays the colour
val red = "\u001b[31m"
val backgroundBrightRed = "\u001b[41;1m"
// displays the decoration
val bold = "\u001b[1m"
// resets colour and decoration back to what it previously was
val reset = "\u001b[0m"
return if (numberOfYoutubers() == 0) "\n No videos stored"
else {
var listOfCats = ""
for (youtube in youtubers) {
for (video in youtube.videos) {
if (video.videoTitle.contains(searchString, ignoreCase = true)) {
listOfCats += "${video}\n"
listOfCats += "\n$backgroundBrightRed $reset$red$bold Video ${video.videoId}$reset\n" +
"$red$bold↳ Title:$reset ${video.videoTitle}\t$red$bold Interaction:$reset ${video.isVideoLiked}\t$red$bold Category:$reset ${video.videoCategory}\t$red$bold Watched status:$reset ${video.watchedStatus}\t$red$bold Rating:$reset ${video.videoRating} \n"
}
}
}
Expand All @@ -206,13 +221,21 @@ class YoutuberAPI(serializerType: Serializer) {
* This function is for searching for a Video in an arraylist by category.
*/
fun searchVideoByCategory(searchString: String): String {
// displays the colour
val red = "\u001b[31m"
val backgroundBrightRed = "\u001b[41;1m"
// displays the decoration
val bold = "\u001b[1m"
// resets colour and decoration back to what it previously was
val reset = "\u001b[0m"
return if (numberOfYoutubers() == 0) "\n No videos stored"
else {
var listOfCats = ""
for (youtube in youtubers) {
for (video in youtube.videos) {
if (video.videoCategory.contains(searchString, ignoreCase = true)) {
listOfCats += "${video}\n"
listOfCats += "\n$backgroundBrightRed $reset$red$bold Video ${video.videoId}$reset\n" +
"$red$bold↳ Title:$reset ${video.videoTitle}\t$red$bold Interaction:$reset ${video.isVideoLiked}\t$red$bold Category:$reset ${video.videoCategory}\t$red$bold Watched status:$reset ${video.watchedStatus}\t$red$bold Rating:$reset ${video.videoRating} \n"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/utils/Utilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object Utilities {
fun formatSetString(itemsToFormat: MutableSet<Video>): String =
itemsToFormat
.joinToString(separator = "\n") { video ->
"$backgroundBrightRed $reset$red$bold Video ${video.videoId}$reset\n" +
"\n$backgroundBrightRed $reset$red$bold Video ${video.videoId}$reset\n" +
"$red$bold↳ Title:$reset ${video.videoTitle}\t$red$bold Interaction:$reset ${video.isVideoLiked}\t$red$bold Category:$reset ${video.videoCategory}\t$red$bold Watched status:$reset ${video.watchedStatus}\t$red$bold Rating:$reset ${video.videoRating} \n"
}

Expand Down
1 change: 0 additions & 1 deletion src/test/kotlin/controllers/YoutuberAPITest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ class YoutuberAPITest {
fun `listWatchedVideos returns the videos marked as watched when ArrayList has non-favourite Youtubers stored`() {
assertEquals(1, populatedYoutubers!!.numberOfWatchedVideos())
val watchedYoutubersString = populatedYoutubers!!.listWatchedVideos().lowercase()
assertTrue(watchedYoutubersString.contains("ksi"))
assertFalse(watchedYoutubersString.contains("PewDiePie"))
assertFalse(watchedYoutubersString.contains("Molly Mae Hague"))
}
Expand Down

0 comments on commit bef073a

Please sign in to comment.