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:
------------------------------------------------------------------------------------------------------------
apartmentRental Code.java:476: '.class' expected
Bubblesort(cust omer[], n );
^
apartmentRental Code.java:476: ')' expected
Bubblesort(cust omer[], 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[myCustomerLinke dList.sizeOfCus tomerList() - 1];
int[] cusIDArray = new int[myCustomerLinke dList.sizeOfCus tomerList()-1];
int z = 0;
File fileName = new File("C:\\Users \\Sony\\Desktop \\ComputerScien ceDossier\\Java Code3\\customer InBinary.dat");
int cusID = 0;
customerDetails readCustomerRec ord = 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 {
RandomAccessFil e raf = new RandomAccessFil e(fileName, "r");
raf.seek(0);
try {
while (true){
status = raf.readChar();
readCustomerRec ord.cusID = raf.readInt();
for(j=0; j<30; j++) {
fName[j] = raf.readChar();
}
readCustomerRec ord.fName = readCustomerRec ord.fName.copyV alueOf(fName);
for(j=0; j<30; j++) {
lName[j] = raf.readChar();
}
readCustomerRec ord.lName = readCustomerRec ord.lName.copyV alueOf(lName);
for(j=0; j<10; j++) {
dob[j] = raf.readChar();
}
readCustomerRec ord.dob = readCustomerRec ord.dob.copyVal ueOf(dob);
for(j=0; j<10; j++) {
passportNo[j] = raf.readChar();
}
readCustomerRec ord.passportNo = readCustomerRec ord.passportNo. copyValueOf(pas sportNo);
for(j=0; j<10; j++) {
mobileNo[j] = raf.readChar();
}
readCustomerRec ord.mobileNo = readCustomerRec ord.mobileNo.co pyValueOf(mobil eNo);
for(j=0; j<50; j++) {
email[j] = raf.readChar();
}
readCustomerRec ord.email = readCustomerRec ord.email.copyV alueOf(email);
cusIDArray[z] = readCustomerRec ord.cusID;
customer[z] = readCustomerRec ord;
}
}
catch (EOFException eof){
raf.close();
}
catch (IOException E){
System.out.prin tln( "Problems reading " + fileName );
raf.close();
}
}
catch (IOException X){
System.out.prin tln("IO Problems with " + fileName );
}
int a = 0;
int n =myCustomerLink edList.sizeOfCu stomerList()-1;
System.out.prin tln(n);
Bubblesort(cust omer[], n );
for(a = 0; a < n; a++){
System.out.prin tln(cusIDArray[a]);
}
}
public void Bubblesort (customerDetail s 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
------------------------------------------------------------------------------------------------------------
apartmentRental Code.java:476: '.class' expected
Bubblesort(cust omer[], n );
^
apartmentRental Code.java:476: ')' expected
Bubblesort(cust omer[], 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[myCustomerLinke dList.sizeOfCus tomerList() - 1];
int[] cusIDArray = new int[myCustomerLinke dList.sizeOfCus tomerList()-1];
int z = 0;
File fileName = new File("C:\\Users \\Sony\\Desktop \\ComputerScien ceDossier\\Java Code3\\customer InBinary.dat");
int cusID = 0;
customerDetails readCustomerRec ord = 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 {
RandomAccessFil e raf = new RandomAccessFil e(fileName, "r");
raf.seek(0);
try {
while (true){
status = raf.readChar();
readCustomerRec ord.cusID = raf.readInt();
for(j=0; j<30; j++) {
fName[j] = raf.readChar();
}
readCustomerRec ord.fName = readCustomerRec ord.fName.copyV alueOf(fName);
for(j=0; j<30; j++) {
lName[j] = raf.readChar();
}
readCustomerRec ord.lName = readCustomerRec ord.lName.copyV alueOf(lName);
for(j=0; j<10; j++) {
dob[j] = raf.readChar();
}
readCustomerRec ord.dob = readCustomerRec ord.dob.copyVal ueOf(dob);
for(j=0; j<10; j++) {
passportNo[j] = raf.readChar();
}
readCustomerRec ord.passportNo = readCustomerRec ord.passportNo. copyValueOf(pas sportNo);
for(j=0; j<10; j++) {
mobileNo[j] = raf.readChar();
}
readCustomerRec ord.mobileNo = readCustomerRec ord.mobileNo.co pyValueOf(mobil eNo);
for(j=0; j<50; j++) {
email[j] = raf.readChar();
}
readCustomerRec ord.email = readCustomerRec ord.email.copyV alueOf(email);
cusIDArray[z] = readCustomerRec ord.cusID;
customer[z] = readCustomerRec ord;
}
}
catch (EOFException eof){
raf.close();
}
catch (IOException E){
System.out.prin tln( "Problems reading " + fileName );
raf.close();
}
}
catch (IOException X){
System.out.prin tln("IO Problems with " + fileName );
}
int a = 0;
int n =myCustomerLink edList.sizeOfCu stomerList()-1;
System.out.prin tln(n);
Bubblesort(cust omer[], n );
for(a = 0; a < n; a++){
System.out.prin tln(cusIDArray[a]);
}
}
public void Bubblesort (customerDetail s 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
Comment