Image

Imagealistairg wrote in Imagejava_dev

Object Orientation

Ok, quick question - I'll try to explain it as well as possible.

In a java program I have a couple of classes - one to store cars and one to store customers. These are owned by an "entities" class that reads text files and creates the customer and car objects using the classes.

Other parts of the app want to be able to access the details of customers and cars, for example to match people to cars. Sometimes the whole set of details are wanted, sometimes I only want to know a few of the properties. At the moment I'm just creating a ShowDetails method that just returns some values. for example:

ShowDetails(1)

returns:
(ford, mondeo, 2000, white) etc...


Is there a more efficient way of doing this? I was never very clear on passing objects as opposed to variables.

Thanks a lot.

Edit: To clear things up, the idea of the system is to match people to potential cars, not to have people permananently linked to them. Sorry, my bad wording