Created
March 6, 2017 22:16
-
-
Save JDRamosC/7deb938da2ba42827be238539cb97412 to your computer and use it in GitHub Desktop.
JDRamosC - Práctica Nro. 1 - Ingenieria en Sistemas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package bo.edu.ubi; | |
| /** | |
| * Created by HP-PC on 04/03/2017. | |
| */ | |
| public class Cancion { | |
| private String nombre; | |
| private String artista; | |
| private String albun; | |
| private int duracion; | |
| public Cancion(String nombre, String artista, String albun, int duracion) { | |
| this.nombre = nombre; | |
| this.artista = artista; | |
| this.albun = albun; | |
| this.duracion = duracion; | |
| } | |
| public Cancion() { | |
| this.nombre = ""; | |
| this.artista = ""; | |
| this.albun = ""; | |
| this.duracion = 0; | |
| } | |
| public String getNombre() { | |
| return nombre; | |
| } | |
| public void setNombre(String nombre) { | |
| this.nombre = nombre; | |
| } | |
| public String getArtista() { | |
| return artista; | |
| } | |
| public void setArtista(String artista) { | |
| this.artista = artista; | |
| } | |
| public String getAlbun() { | |
| return albun; | |
| } | |
| public void setAlbun(String albun) { | |
| this.albun = albun; | |
| } | |
| public int getDuracion() { | |
| return duracion; | |
| } | |
| public void setDuracion(int duracion) { | |
| this.duracion = duracion; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package bo.edu.ubi; | |
| /** | |
| * Created by HP-PC on 04/03/2017. | |
| */ | |
| public class Main { | |
| public static void main(String[] args) { | |
| //Lista de Canciones | |
| System.out.println("-----------------------------Lista de canciones del Momento--------------------------------"); | |
| Cancion[] canciones = new Cancion[5]; | |
| canciones[0] = new Cancion("4 babys", "Maluma ft. Brayan Mayers", "Pretty boy", 256); | |
| canciones[1] = new Cancion("Sexo, sudor y calor", "J Alvares ft Ñejo y Dalmata", "El dueño del Sistema", 197); | |
| canciones[2] = new Cancion("Si me dices que si", "Nicky Jam ft Cosculluela", "Blanco perla", 177); | |
| canciones[3] = new Cancion("La Rompe corazones", "Daddy Yankee ft Ozuna", "Cabee Music", 183); | |
| canciones[4] = new Cancion("Ojala pudiera borrarte", "Maná", "Lluvia al corazón", 302); | |
| for (int i = 0; i < 5; i++) { | |
| Cancion c = canciones[i]; | |
| System.out.println("Cancion (" + (i + 1) + "): [" + c.getNombre() + "] Artista: [ " + c.getArtista() + "] Albun : [ " + c.getAlbun() + "] Duracion: [" + c.getDuracion() + "]"); | |
| } | |
| //Codigo para saber cual es la cancion con maxima duracion | |
| System.out.println("La cancion con mas durcacion de la lista es:"); | |
| Cancion max = canciones[0]; | |
| for (int i = 0; i < canciones.length; i++) { | |
| if (max.getDuracion() < canciones[i].getDuracion()) { | |
| max = canciones[i]; | |
| } | |
| } | |
| System.out.println(" Cancion: [" + max.getNombre() + "] Artista: [ " + max.getArtista() + "] Albun : [ " + max.getAlbun() + "] Duracion: [" + max.getDuracion() + "]"); | |
| //Codigo para saber cual es la cancion con minima duracion | |
| System.out.println("La cancion con menos durcacion de la lista es:"); | |
| Cancion men = canciones[0]; | |
| for (int i = 0; i < canciones.length; i++) { | |
| if (men.getDuracion() > canciones[i].getDuracion()) { | |
| men = canciones[i]; | |
| } | |
| } | |
| System.out.println(" Cancion : [" + men.getNombre() + "] Artista: [ " + men.getArtista() + "] Albun : [ " + men.getAlbun() + "] Duracion: [" + men.getDuracion() + "]"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment