Last active
March 4, 2017 23:21
-
-
Save PabloSanchezMartinez/112569873116e6413dea27f0a440ad40 to your computer and use it in GitHub Desktop.
Pablo Javier Sanchez Martinez (Main solución eficaz con linea de código corta) Orginal
This file contains 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.ubi.lapaz; | |
public class Cancion { | |
//Atributos | |
String titulo, album, artista; | |
int dur; | |
//Contructor con parametros | |
public Cancion(String titulo, String album, String artista, int dur) { | |
this.titulo = titulo; | |
this.album = album; | |
this.artista = artista; | |
this.dur = dur; | |
} | |
//contructor sin parametros | |
public Cancion( ) { | |
} | |
//Metodos Getters | |
public String getTitulo() { | |
return titulo; | |
} | |
public String getAlbum() { | |
return album; | |
} | |
public String getArtista() { | |
return artista; | |
} | |
public int getDur() { | |
return dur; | |
} | |
// Metodos Setters | |
public void setArtista(String artista) { | |
this.artista = artista; | |
} | |
public void setAlbum(String album) { | |
this.album = album; | |
} | |
public void setTitulo(String titulo) { | |
this.titulo = titulo; | |
} | |
public void setDur(int dur) { | |
this.dur = dur; | |
} | |
} |
This file contains 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.ubi.lapaz; | |
public class Main { | |
public static void main(String[] args) { | |
// creo las 10 canciones | |
Cancion c1 = new Cancion("Aquellare", "La voz Dormida cd 1", "Mago de Oz", 8); | |
Cancion c2 = new Cancion("Be Quick Or Be Dead", "Best Of The Beast (CD1)", "Iron Maiden", 3); | |
Cancion c3 = new Cancion("Black Widow of La Porte", "The Devil Knows My Name", "John 5", 7); | |
Cancion c4 = new Cancion("Kill With Power", "Hail To England", "Manowar", 4); | |
Cancion c5 = new Cancion("La Cantata Del Diablo", "La voz Dormida cd 2", "Mago de oz", 21); | |
Cancion c6 = new Cancion("Antigiles", "Antigiles", "Krauss", 4); | |
Cancion c7 = new Cancion("Desde El Ataúd", "Titere Con Cabeza", "Leo Jimenez", 4); | |
Cancion c8 = new Cancion("Noche Acosador", "God Told Me To", "John 5", 3); | |
Cancion c9 = new Cancion("Dead Girl Superstar", "The Sinister Urge", "Rob Zombie", 2); | |
Cancion c10 = new Cancion("Tan Lejos De Aquel Sueño", "Tormenta Electrica", "Rata Blanca", 5); | |
Cancion c11 = new Cancion("Slither", "Contraband", "Velvet Revolver", 4); | |
Cancion c12 = new Cancion("Vendetta", "All Hop Is Gone", "Slipknot", 5); | |
Cancion c13 = new Cancion("Rock N Roll Music", "The World Is Yours", "Motörhead", 4); | |
Cancion c14 = new Cancion("La luna en ti 2.0", "Celtic Land", "Mago de Oz", 4); | |
Cancion c15 = new Cancion("Mi color preferido eres tú", "Si Dios está en todas partes...", "Bürdel King;", 4); | |
//creo el Array para las Canciones | |
Cancion[] arraycancion = new Cancion[15]; | |
//Agrego las canciones al Array | |
arraycancion[0] = c1; | |
arraycancion[1] = c2; | |
arraycancion[2] = c3; | |
arraycancion[3] = c4; | |
arraycancion[4] = c5; | |
arraycancion[5] = c6; | |
arraycancion[6] = c7; | |
arraycancion[7] = c8; | |
arraycancion[8] = c9; | |
arraycancion[9] = c10; | |
arraycancion[10] = c11; | |
arraycancion[11] = c12; | |
arraycancion[12] = c13; | |
arraycancion[13] = c14; | |
arraycancion[14] = c15; | |
//Metodo para sacar la cancion de mayor duracion | |
Cancion can = arraycancion[0]; | |
for (int i = 1; i < arraycancion.length; i++) { | |
if (can.getDur() < arraycancion[i].getDur()) { | |
can = arraycancion[i]; | |
} | |
} | |
//imprimiendo los resultados | |
System.out.println("La cancion con mas duracion dentro del Array de Canciones es: "); | |
System.out.println("---------------------------------------------------------------"); | |
System.out.println("Titulo: " + can.getTitulo()); | |
System.out.println("ALbum: " + can.getAlbum()); | |
System.out.println("Artista: " + can.getArtista()); | |
System.out.println("Duracion:: " + can.getDur() + " min"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment