Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Sorting program Posted by Archestic on 9 May 2007 at 8:15 AM
We are in the process of creating a program which will take in a number of customers and match them to their favourite cars based on a number of fields.

The customers are stored as objects in an array, which is the same as the cars (objects in an array). We are trying to find the esiest was of comapring the 2 arrays which will then leave the customer with a number of cars which they might be interested in. Some of the criteria which not all objects have are, price, number of doors, type, MPG, colour. I am looking for some suggestions and help on how i could go about this. Anything will be useful

---
ArcH
Report
Re: Sorting program Posted by zibadian on 9 May 2007 at 10:28 AM
: We are in the process of creating a program which will take in a
: number of customers and match them to their favourite cars based on
: a number of fields.
:
: The customers are stored as objects in an array, which is the same
: as the cars (objects in an array). We are trying to find the esiest
: was of comapring the 2 arrays which will then leave the customer
: with a number of cars which they might be interested in. Some of the
: criteria which not all objects have are, price, number of doors,
: type, MPG, colour. I am looking for some suggestions and help on how
: i could go about this. Anything will be useful
:
: ---
: ArcH
Tjheeasiest (and slowest) sorting algorithm is the bubble sort. The algorithm is well described on the wikipedia.com.
Perhaps you meant a filter. This will show only array-elements, which conform to certain criteria. This can easiest be done using a for-loop and an if-statement:
   for (Car c : cars) {
     if ((c.price >= customer.minPrice) && (c.price <= customer.maxPrice)) {
        showCar();
     }  
   }
Report
Re: Pairing program Posted by Archestic on 9 May 2007 at 12:46 PM
I dont know if anyone will bble to help with this question but i keep getting thr error, "The constructor Car() is undefined".
I dont know what could be causing this error becuase a similar piece of code is not throwing the error.
All i have done is copied and changed the variables.

Report
Re: Pairing program Posted by zibadian on 9 May 2007 at 2:27 PM
: I dont know if anyone will bble to help with this question but i
: keep getting thr error, "The constructor Car() is undefined".
: I dont know what could be causing this error becuase a similar piece
: of code is not throwing the error.
: All i have done is copied and changed the variables.
:
:
Appearantly you don't have the null-argument constructor for your class defined. Solution:
- Either define the null-argument constructor
- Change the creation code to include arguments.



 

Recent Jobs