Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 4th, 2005, 9:00 AM   #1
zip2kx
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 zip2kx is on a distinguished road
java bubble sort help

Right i cant get it to work and im out of ideas so some programmring guru plz help T__T

this is my bubblesort class file:
public class sort{

public static void bubbelSort(film data[]){
	for (int m = data.lenght -1; m > 0; m--){
		for (int n = 0; n < m; n++){
			if(data[n].langd > data[n+1].langd){
				int temp = data[n].langd;
				data[n].langd = data[n+1].langd;
				data[n+1].langd = temp;
			}
		}
	}
}
}
//
and this the part that calls the class in my app
//
sort.bubbelSort(film);
		
		System.out.print("Sorterad efter langd: ");
		for (int i = 0; i < 5; i++){
			System.out.print(film[i] + " ");
		}

note that it's in a case.
and the error i get when i javac it
//
D:\Java grejer>javac inlupp_DVDDaAr.java
.\sort.java:3: cannot resolve symbol
symbol  : class film
location: class sort
public static void bubbelSort(film data[]){
                              ^
1 error
Anything helpful is accepted
zip2kx is offline   Reply With Quote
Old Mar 4th, 2005, 9:14 AM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
what's film? is there a class called film? you're passing film into the sort method, but that's the name of the variable, when you create film, you must do something like [Class] film = new [Class]() the name of the Class is the Type of variable you're passing through.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Mar 4th, 2005, 9:26 AM   #3
zip2kx
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 zip2kx is on a distinguished road
oh crap forgot that. Film is a "array" (i think... im translating from swedish -> english so it might be wrong)

i used it to
DVDDaAr film[]=new DVDDaAr[100];

DVDDAaAr is the main class file that sorts the other information that i send in (it works ).
zip2kx is offline   Reply With Quote
Old Mar 4th, 2005, 9:59 AM   #4
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
ok, so DVDaAr data[] is what you wanna accept in sort()
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Mar 4th, 2005, 11:13 AM   #5
zip2kx
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 zip2kx is on a distinguished road
So it's

sort.bubbelSort(DVDDaAr data[]);

? or did i get it wrong?

edit: changed some stuff. i Changed
Public static void bubbelSort(film data[]){

to

Public static void bubbelSort(DVDDaAr data[]){

and

for (int m = data.lenght -1; m > 0; m--){
to
for (int m = data.length -1; m >0; m--){

every .langd 
to
.hamtaLangd

.hamtaLangd is a getter which returns a int.

and now im stuck with these 2 last errors

.\sort.java:8: unexpected type
required: variable
found   : value
                                data[n].hamtaLangd() = data[n+1].hamtaLangd();
                                                  ^
.\sort.java:9: unexpected type
required: variable
found   : value
                                data[n+1].hamtaLangd() = temp;
                                                    ^
2 errors

Last edited by zip2kx; Mar 4th, 2005 at 12:04 PM.
zip2kx is offline   Reply With Quote
Old Mar 4th, 2005, 12:37 PM   #6
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
what's hamtaLangd?
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Mar 4th, 2005, 12:53 PM   #7
zip2kx
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 zip2kx is on a distinguished road
a method that returns a private value
zip2kx is offline   Reply With Quote
Old Mar 4th, 2005, 1:47 PM   #8
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
looks like you're not calling it according to it's signature
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Mar 9th, 2005, 9:00 PM   #9
meribia_pro_software
Newbie
 
Join Date: Mar 2005
Posts: 4
Rep Power: 0 meribia_pro_software is on a distinguished road
Hello all, I'm new to this forum, but I consider myself an expert in Java (as well as in 6 other computer languages). I think I can help out with this problem if anyone's still paying attention to this thread ....

I wrote a small C++ routine that implements the Bubble Sort algorithm a while back and it should be able to be ported to Java quite easily. Here it is:

void SortObject::bubbleSort () {

int i;
int tmp;

for ( i = 0; i < count - 1; i++ ) {
if ( array[i] > array[i+1] ) {
tmp = array[i];
array[i] = array[i+1];
array[i+1] = tmp;
i = 0;
}
}

}

--------------------------------------------------------------------------------

Download SortObject++: veritedonato.cihost.com/sort.zip
MainWebsite: veritassoftwarecreations.net/
meribia_pro_software is offline   Reply With Quote
Old Mar 9th, 2005, 9:02 PM   #10
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
his problem wasn't the algorithm, he had some syntax errors in his code.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC