Hi, I am doing an apartment rentals program but i need to bubble sort the array of a user defined class customerDetails (this entails all the details of the customer) However, when i am calling that there is an error:
------------------------------------------------------------------------------------------------------------
apartmentRentalCode.java:476: '.class' expected
Bubblesort(customer[], n );
^
apartmentRentalCode.java:476: ')' expected
Bubblesort(customer[], n );
^
2 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
--------------------------------------------------------------------------------------------------------------
Here is the code:
public void sortCustomer()
{
customerDetails[] customer = new customerDetails[myCustomerLinkedList.sizeOfCustomerList() - 1];
int[] cusIDArray = new int[myCustomerLinkedList.sizeOfCustomerList()-1];
int z = 0;
File fileName = new File("C:\\Users\\Sony\\Desktop\\ComputerScienceDos sier\\JavaCode3\\customerInBinary.dat");
int cusID = 0;
customerDetails readCustomerRecord = new customerDetails();
char status;
char[] fName = new char[30];
char[] lName = new char[30];
char[] dob = new char[10];
char[] passportNo = new char[10];
char[] mobileNo = new char[10];
char[] email = new char[50];
int j = 0;
try {
RandomAccessFile raf = new RandomAccessFile(fileName, "r");
raf.seek(0);
try {
while (true){
status = raf.readChar();
readCustomerRecord.cusID = raf.readInt();
for(j=0; j<30; j++) {
fName[j] = raf.readChar();
}
readCustomerRecord.fName = readCustomerRecord.fName.copyValueOf(fName);
for(j=0; j<30; j++) {
lName[j] = raf.readChar();
}
readCustomerRecord.lName = readCustomerRecord.lName.copyValueOf(lName);
for(j=0; j<10; j++) {
dob[j] = raf.readChar();
}
readCustomerRecord.dob = readCustomerRecord.dob.copyValueOf(dob);
for(j=0; j<10; j++) {
passportNo[j] = raf.readChar();
}
readCustomerRecord.passportNo = readCustomerRecord.passportNo.copyValueOf(passport No);
for(j=0; j<10; j++) {
mobileNo[j] = raf.readChar();
}
readCustomerRecord.mobileNo = readCustomerRecord.mobileNo.copyValueOf(mobileNo);
for(j=0; j<50; j++) {
email[j] = raf.readChar();
}
readCustomerRecord.email = readCustomerRecord.email.copyValueOf(email);
cusIDArray[z] = readCustomerRecord.cusID;
customer[z] = readCustomerRecord;
}
}
catch (EOFException eof){
raf.close();
}
catch (IOException E){
System.out.println( "Problems reading " + fileName );
raf.close();
}
}
catch (IOException X){
System.out.println("IO Problems with " + fileName );
}
int a = 0;
int n =myCustomerLinkedList.sizeOfCustomerList()-1;
System.out.println(n);
Bubblesort(customer[], n );
for(a = 0; a < n; a++){
System.out.println(cusIDArray[a]);
}
}
public void Bubblesort (customerDetails data[],int n) {
int i,j;
customerDetails tmp;
for (i=0; i<n-1; i++) {
for (j=0; j<n-i-1; j++)
if (data[j].cusID > data[j+1].cusID) {
tmp = data[j];
data[j] = data[j+1];
data[j+1] = tmp;
}
}
}
--------------------------------------------------------------------------------------------------------------
can u please help me figure this out...my brain is dead after hours of fiddling around...
cheers x