Ektufy.java
This Java class implements a basic playlist manager. You can add songs to the playlist and play them at normal speed or at a specified speed. It includes handling for a full playlist and checking if a song exists before playing it.FGZBRACU
java
17 days ago
1.9 kB
8
Indexable
CSE111 Lab Quiz Codes
public class Ektufy { String [] playList = new String[3]; int count = 0; String genre = "Default"; public void addSong(String song) { if (count < playList.length) { playList[count] = song; count++; System.out.println("Added: " + song + " to the playlist."); } else { System.out.println("Playlist is full."); } } public void play(String songName) { for (int i = 0; i < count; i++) { if (playList[i].equals(songName)) { System.out.println("Playing: " + playList[i] + " in " + genre + " genre."); return; } } System.out.println("Song not found in the playlist."); } public void play(String songName, Double speed) { for (int i = 0; i < count; i++) { if (playList[i].equals(songName)) { System.out.println("Playing: " + playList[i] + " at " + speed + "x speed."); return; } } System.out.println("Song not found in the playlist."); } public void play(String songName, String language) { for (int i = 0; i < count; i++) { if (playList[i].equals(songName)) { System.out.println("Playing: " + playList[i] + " in " + language + " language."); return; } } System.out.println("Song not found in the playlist."); } public void displayPlaylist() { System.out.println("Genre: " + genre); System.out.println("Playlist:"); if (count == 0) { System.out.println("No songs in the playlist."); return; } System.out.println("Total songs: " + count); for (int i = 0; i < count; i++) { System.out.println(playList[i]); } } }
Editor is loading...
Leave a Comment