package com.aluracourses.spotifeli.models;
import java.time.Duration;
public class Audio {
private String title;
private String creatorName;
private int totalPlays;
private int totalLikes;
private int classification;
public int getClassification() {
return classification;
}
public void setClassification(int classification) {
this.classification = classification;
}
public int getTotalLikes() {
return totalLikes;
}
public void setTotalLikes(int totalLikes) {
this.totalLikes = totalLikes;
}
public int getTotalPlays() {
return totalPlays;
}
public void setTotalPlays(int totalPlays) {
this.totalPlays = totalPlays;
}
public String getCreatorName() {
return creatorName;
}
public void setCreatorName(String creatorName) {
this.creatorName = creatorName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public void like(){
this.totalLikes++;
}
public void play(){
this.totalPlays++;
}
}
package com.aluracourses.spotifeli.models;
public class Song extends Audio {
private String genre;
private String album;
private int lengthSeconds;
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getAlbum() {
return album;
}
public void setAlbum(String album) {
this.album = album;
}
public int getLengthSeconds() {
return lengthSeconds;
}
public void setLengthSeconds(int lengthSeconds) {
this.lengthSeconds = lengthSeconds;
}
@Override
public int getClassification() {
if (getTotalLikes()>5000) {
return 8;
} else {
return 4;
}
}
}
package com.aluracourses.spotifeli.models;
public class Podcast extends Audio {
private String topic;
private String description;
private String language;
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
@Override
public int getClassification() {
if (getTotalPlays()>5000) {
return 8;
} else {
return 4;
}
}
}
package com.aluracourses.spotifeli.models;
public class FavoriteList {
public void add(Audio audio){
if(audio.getClassification() >=8) {
System.out.println(audio.getTitle() + " es uno de los favoritos del catálogo");
} else {
System.out.println("Reproduce " + audio.getTitle() + " y averigua si te gusta esta pieza");
}
}
}
package com.aluracourses.spotifeli.main;
import com.aluracourses.spotifeli.models.FavoriteList;
import com.aluracourses.spotifeli.models.Podcast;
import com.aluracourses.spotifeli.models.Song;
public class Main {
public static void main(String[] args) {
Song song1 = new Song();
song1.setTitle("Johnny Glamour");
song1.setAlbum("DAISY");
song1.setGenre("Electronic");
song1.setCreatorName("rusowsky, Las Ketchup");
song1.setLengthSeconds(141);
Podcast podcast1 = new Podcast();
podcast1.setTitle("Grandes Maricas de la Historia");
podcast1.setTopic("History");
podcast1.setDescription("Clever narration of the life and work of great queer people in history");
podcast1.setLanguage("Spanish");
podcast1.setCreatorName("Otto Mas");
for (int i = 0; i < 5600; i++) {
song1.like();
}
for (int i = 0; i < 313515; i++) {
song1.play();
}
for (int i = 0; i < 100; i++) {
podcast1.like();
}
for (int i = 0; i < 3100; i++) {
podcast1.play();
}
System.out.println(song1.getTitle() + " de " + song1.getCreatorName() + " ha tenido " + song1.getTotalPlays() + " reproducciones");
System.out.println(song1.getTitle() + " de " + song1.getCreatorName() + " ha tenido " + song1.getTotalLikes() + " likes en la plataforma");
FavoriteList favorites = new FavoriteList();
favorites.add(song1);
favorites.add(podcast1);
}
}