Created
March 4, 2017 22:12
-
-
Save PabloSanchezMartinez/23f35278d07cc19da1fb25b484475d61 to your computer and use it in GitHub Desktop.
Pablo Javier Sanchez Martinez
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); | |
//creo el Array para las Canciones | |
Cancion[] arraycancion = new Cancion[8]; | |
//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; | |
//Metodo para sacar la cancion de mayor duracion | |
Cancion mayor = new Cancion(); | |
if (arraycancion[0].getDur() > arraycancion[1].getDur()) | |
mayor = arraycancion[0]; | |
else | |
mayor = arraycancion[1]; | |
Cancion mayor1 = mayor; | |
if (arraycancion[2].getDur() > arraycancion[3].getDur()) | |
mayor = arraycancion[2]; | |
else | |
mayor = arraycancion[3]; | |
Cancion mayor2 = mayor; | |
if (arraycancion[4].getDur() > arraycancion[5].getDur()) | |
mayor = arraycancion[4]; | |
else | |
mayor = arraycancion[5]; | |
Cancion mayor3 = mayor; | |
if (arraycancion[6].getDur() > arraycancion[7].getDur()) | |
mayor = arraycancion[6]; | |
else | |
mayor = arraycancion[7]; | |
Cancion mayor4 = mayor; | |
if (mayor1.getDur() > mayor2.getDur()) | |
mayor = mayor1; | |
else | |
mayor = mayor2; | |
Cancion MAY = mayor; | |
if (mayor3.getDur() > mayor4.getDur()) | |
mayor = mayor3; | |
else | |
mayor = mayor4; | |
Cancion MAY1 = mayor; | |
System.out.println("La cancion con mas duracion dentro del Array de Canciones es: "); | |
System.out.println("---------------------------------------------------------------"); | |
if(MAY1.getDur()>MAY.getDur()) { | |
System.out.println("Titulo: " + MAY1.getTitulo()); | |
System.out.println("ALbum: " + MAY1.getAlbum()); | |
System.out.println("Artista: " + MAY1.getArtista()); | |
System.out.println("Duracion:: " + MAY1.getDur()+" min"); | |
}else { | |
System.out.println("Titulo: " + MAY.getTitulo()); | |
System.out.println("ALbum: " + MAY.getAlbum()); | |
System.out.println("Artista: " + MAY.getArtista()); | |
System.out.println("Duracion:: " + MAY.getDur()+" min"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment