i need some help in order to finish a work.
the "program" works reading a file.txt with a list of songs that are write in this way
Out Of The silent Planet -Iron Maiden -Brave New World -2000 -Metal.wma
Ghost of the Navigator -Iron Maiden -Brave New World -2000 -Metal.wma
Say Goodbye -Reel Bigfish - Were not happy till you are not happy -2005 - ska.wma
Somebody hates me -Reel Bigfish - Were not happy till you are not happy -2005 - ska.wma
brand new song -Reel Bigfish - Were not happy till you are not happy -2005 - ska.mp3
then transforming it in an "arrainge" of strings.
The problem that i have to solve is to:
1.-take all this song Strings , creating an other arrainge, but this time of songs called temas.
every temas have :
String titulo;-> tittle of the song
String interprete;->band
String album;
String año;->year
String genero;->rock, pop, punk etc...
String formato;->format mp3. wma. etc...
then i have to order it by tittle, then album, genero( rock pop punk etc.), print the band with his albums and songs, print the band with more songs, the oldest album and the newest one and print the One hits wonders( bands with one song)
the code of all 3 classes:
class convertor(transform the arrainge of Strings in to the arrainge of temas(songs):
[import smt.SongLoader;
import consola.*;
public class convertor {
temas [] listadetemas;
int validador=0;
public convertor(){}
public int CargarCanciones(){
SongLoader s1= new SongLoader("songnames.txt");
String[] songnames = s1.getSongList();
for(int i=0;i<songnames.length;i++){
songnames[i].toLowerCase();
for(int j=0;j<songnames[i].length();j++){
if(songnames[i].charAt(j)==' '&&songnames[i].charAt(j+1)==' '){
songnames[i]=songnames[i].substring(0,j)+songnames[i].substring(j);
}
if(songnames[i].charAt(j)=='-'&&songnames[i].charAt(j+1)==' '){
}
}
for(int j=0;j<songnames[i].length();j++){
songnames[i].substring(0, 0).toUpperCase();
if(songnames[i].charAt(j)=='-'){
songnames[i].substring(j+1, j+1).toUpperCase();
}
}
if(songnames[i].equals(songnames[i+1])){
Consola.MostrarMensaje(songnames[i]+"\n"+
songnames[i+1]);
}
}
listadetemas=new temas[songnames.length];
for(int i=0;i<songnames.length;i++){
listadetemas[i]=new temas(null,null,null,null,null,null);
}
for(int i=0;i<songnames.length;i++){
listadetemas[i].setTitulo(songnames[i].substring(0,songnames[i].indexOf('-')));
listadetemas[i].setAlbum(songnames[i].substring(songnames[i].indexOf('-',songnames[i].indexOf('-')+1)));
listadetemas[i].setGenero(songnames[i].substring(songnames[i].lastIndexOf('-'),songnames[i].lastIndexOf('.')));
listadetemas[i].setAño(songnames[i].substring(songnames[i].lastIndexOf('-',songnames[i].lastIndexOf('-')-1),songnames[i].lastIndexOf('-')));
listadetemas[i].setFormato(songnames[i].substring(songnames[i].lastIndexOf('.')));
listadetemas[i].setInterprete(songnames[i].substring(songnames[i].indexOf('-'),songnames[i].indexOf('-',songnames[i].indexOf('-')+1)));
}
return validador++;
}
public boolean OrdenarPorTitulo(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
boolean intercambio=false;
do{
intercambio=false;
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getTitulo().compareToIgnoreCase(listadetemas[i+1].getTitulo())<0){
temas tmp=listadetemas[i];
listadetemas[i]=listadetemas[i+1];
listadetemas[i+1]=tmp;
intercambio=true;}
}
}while (intercambio=true);
for(int i=0;i<listadetemas.length;i++){
Consola.MostrarMensaje(listadetemas[i].getTitulo()+"-"+listadetemas[i].getInterprete()+","+listadetemas[i].getAlbum()+" ("+listadetemas[i].getAño()+") ["+listadetemas[i].getGenero()+"]");
}
return true;}
public boolean OrdenarPorAlbum(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
boolean intercambio=false;
do{
intercambio=false;
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getAlbum().compareToIgnoreCase(listadetemas[i+1].getAlbum())<0){
temas tmp=listadetemas[i];
listadetemas[i]=listadetemas[i+1];
listadetemas[i+1]=tmp;
intercambio=true;}
}
}while (intercambio=true);
for(int i=0;i<listadetemas.length;i++){
Consola.MostrarMensaje(listadetemas[i].getAlbum()+"-"+listadetemas[i].getTitulo()+","+listadetemas[i].getInterprete()+", ("+listadetemas[i].getAño()+") ["+listadetemas[i].getGenero()+"]");
}
return true;
}
public boolean OrdenarPorGenero(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
boolean intercambio=false;
do{
intercambio=false;
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getGenero().compareToIgnoreCase(listadetemas[i+1].getGenero())<0){
temas tmp=listadetemas[i];
listadetemas[i]=listadetemas[i+1];
listadetemas[i+1]=tmp;
intercambio=true;}
}
}while (intercambio=true);
for(int i=0;i<listadetemas.length;i++){
Consola.MostrarMensaje(listadetemas[i].getGenero()+"-"+listadetemas[i].getTitulo()+","+listadetemas[i].getInterprete()+", ["+listadetemas[i].getAlbum()+"] ("+listadetemas[i].getAño()+")");
}
return true;
}
public boolean AgruparPorArtistaAlbum(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
String msj="";
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getInterprete()==listadetemas[i+1].getInterprete()){
msj="-"+listadetemas[i].getInterprete()+":\n";
if(listadetemas[i].getAlbum()==listadetemas[i+1].getAlbum()){
msj="-"+listadetemas[i].getInterprete()+":" +
"\n -"+listadetemas[i].getAlbum()+" ("+listadetemas[i].getAño()+")\n";
;}
else{
msj+=" -"+listadetemas[i].getAlbum()+" ("+listadetemas[i].getAño()+")\n";
}
msj+=" +"+listadetemas[i].getTitulo();
}
msj="-"+listadetemas[i].getInterprete()+":\n" +
" -"+listadetemas[i].getAlbum()+" ("+listadetemas[i].getAño()+")\n" +
" +"+listadetemas[i].getTitulo();
}
return true;
}
public boolean ArtistasConMasCanciones(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
for(int i=0;i<listadetemas.length;i++){
int cont=0;
if(listadetemas[i].getInterprete()==listadetemas[i+1].getInterprete()){
cont++;
}
}
return true;
}
public boolean AlbumMasViejo(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
boolean intercambio=false;
do{
intercambio=false;
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getAño().compareToIgnoreCase(listadetemas[i+1].getAño())<0){
temas tmp=listadetemas[i];
listadetemas[i]=listadetemas[i+1];
listadetemas[i+1]=tmp;
intercambio=true;}
}
}while (intercambio=true);
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getAño()==listadetemas[0].getAño())
Consola.MostrarMensaje(listadetemas[i].getAño());
}
return true;
}
public boolean AlbumMasNuevo(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
boolean intercambio=false;
do{
intercambio=false;
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getAño().compareToIgnoreCase(listadetemas[i+1].getAño())<0){
temas tmp=listadetemas[i];
listadetemas[i]=listadetemas[i+1];
listadetemas[i+1]=tmp;
intercambio=true;}
}
}while (intercambio=true);
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getAño()==listadetemas[listadetemas.length-1].getAño())
Consola.MostrarMensaje(listadetemas[i].getAño());
}
return true;
}
public boolean OneHitWonders(){
if(validador==0){Consola.MostrarMensaje("---¡debe cargar canciones!---"); return false;}
for(int i=0;i<listadetemas.length;i++){
if(listadetemas[i].getInterprete()==listadetemas[i+1].getInterprete()){
if(listadetemas[i].getAlbum()==listadetemas[i+1].getAlbum()){
;}}
else Consola.MostrarMensaje("-"+listadetemas[i].getInterprete());
}
return true;
}
}]
class temas, with the atributes of all song.
[import smt.SongLoader;
import consola.*;
public class temas {
String titulo;
String interprete;
String album;
String año;
String genero;
String formato;
public temas(String t,String i,String alb,String a,String g,String f){
t=titulo;
i=interprete;
alb=album;
a=año;
g=genero;
f=formato;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getInterprete() {
return interprete;
}
public void setInterprete(String interprete) {
this.interprete = interprete;
}
public String getAlbum() {
return album;
}
public void setAlbum(String album) {
this.album = album;
}
public String getAño() {
return año;
}
public void setAño(String año) {
this.año = año;
}
public String getGenero() {
return genero;
}
public void setGenero(String genero) {
this.genero = genero;
}
public String getFormato() {
return formato;
}
public void setFormato(String formato) {
this.formato = formato;
}
}
class Cprincipal have the menu that ask the usser what he or she wants to do.
]
[import smt.SongLoader;
import consola.*;
import iic1102Package.Interfaz;
public class Cprincipal {
temas [] listadetemas;
int validador=0;
public static void main(String[] args) {
int n = 0;
convertor c=new convertor();
while(n != 10){
n=Interfaz.PedirEntero("1. Cargar Canciones\n" +
" 2. Ordenar por título\n" +
" 3. Ordenar por álbum\n" +
" 4. Ordenar por género\n" +
" 5. Agrupar por artista y luego por álbum\n" +
" 6. Artistas con más canciones\n" +
" 7. Album más viejo\n" +
" 8. Album más nuevo\n" +
" 9. One-hit-wonders\n" +
"10. Salir");
if(n==1){c.CargarCanciones();}
if(n==2){c.OrdenarPorTitulo();}
if(n==3){c.OrdenarPorAlbum();}
if(n==4){c.OrdenarPorGenero();}
if(n==5){c.AgruparPorArtistaAlbum();}
if(n==6){c.ArtistasConMasCanciones();}
if(n==7){c.AlbumMasViejo();}
if(n==8){c.AlbumMasNuevo();}
if(n==9){c.OneHitWonders();}
if(n==10)break;
}
}
}
]
There is some error in this java code i can't find. It would very helpfull if someone could help me to make it run.
Attached File(s)
-
songnames.txt (2.7K)
Number of downloads: 46 -
1240805969_cnavarrc_sec2_pos0.zip (2.16K)
Number of downloads: 44 -
1240805988_cnavarrc_sec2_pos0.zip (1.71K)
Number of downloads: 40

New Topic/Question
Reply




MultiQuote







|