Ektufy.java
java10 months ago
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]);
}
}
}ChalaiDen.java
java10 months ago
public class ChalaiDen {
String [] sloganList = new String[3];
int count = 0;
String vibe = "Crazy!";
public void addSlogan(String slogan) {
if (count < sloganList.length) {
sloganList[count] = slogan;
count++;
System.out.println("Added " + slogan + " to the slogan list.");
} else {
System.out.println("No more slogan please!");
}
}
public void sayIt(String slogan) {
for (int i = 0; i < count; i++) {
if (sloganList[i].equals(slogan)) {
System.out.println("Chalaiden " + sloganList[i] + " at " + vibe + " vibe.");
return;
}
}
System.out.println("Slogan not found in the list.");
}
public void sayIt(String slogan, int repeatTimes) {
for (int i = 0; i < count; i++) {
if (sloganList[i].equals(slogan)) {
for (int j = 0; j < repeatTimes; j++) {
sloganList[i] += " " + slogan;
}
System.out.println("Chalaiden " + sloganList[i]);
return;
}
}
System.out.println("Slogan not found in the list.");
}
public void sayIt(String slogan, String language) {
for (int i = 0; i < count; i++) {
if (sloganList[i].equals(slogan)) {
System.out.println("Chalaiden " + sloganList[i] + " in " + language + " language.");
return;
}
}
System.out.println("Slogan not found in the list.");
}
public void displaySlogans() {
System.out.println("Vibe: " + vibe);
System.out.println("Slogan List:");
if (count == 0) {
System.out.println("No slogans added yet.");
return;
}
System.out.println("Total slogans: " + count);
for (int i = 0; i < count; i++) {
System.out.println(sloganList[i]);
}
}
}
- Total 2 snippets
- 1