Urgent help required

Hi all,

I have an assignment due next week. I don't realy know simple two way association which this program requires. Here is the requirement.

This exercise is about simple two-way associations. An example of a simple two-way association is the ownership relation between a Person and a Car. To ensure consistency, the following three rules should be obeyed.

Each car is owned by exactly one person, that is, no car is without an owner, and no car is owned by more than one person.

Each Person can own at most one car.

If a person owns a car, that car is owned by that person, and vice versa.

It is common for simple two-way associations that one side X must be associated to the other side Y, while Y might be associated to an X.

Write the two classes Person and Car, such that each has a public (declaring it private will make the exercise much harder) reference field that can refer to one of the other kind, that is, class Person as a field Car car, and class Car has a field Person owner. Hint. Use the constructor of Car to make sure that a car is never created without a owner, this should take care of rule 1 & 2 above.

Add a method void newOwner(Person p) to the car class. It should make p the new owner of this car. Make sure rule 1, 2 & 3 are respected by the method. You may assume that the person p is not the owner of an other car.

I have no clue how to implement this. Could you guys give me some Idea how to design these two classes according to the requirements.

I appreciate your help.

Looking forward to your reply.

Koonda

[1638 byte] By [koondaa] at [2007-11-26 22:18:44]
# 1

Thank you for posting your homework assignment. We'll do it for you without you having to expend any effort of your own. We know school work is very taxing on students, and believe in helping them out this way so they can concentrate on more important matters such as going to parties.

And heaven knows the software industry is desperately in need of more workers, even if they are just warm bodies with no actual capabilities. It does the economy good.

We'll get back to you shortly.

warnerjaa at 2007-7-10 11:13:48 > top of Java-index,Java Essentials,Java Programming...
# 2

<note descrption="Posting a thread as \"urgent\" will get you no help. It will instead get you many sarcastic replies like warnerja\'s. Posting a thread NOT as \"urgent\" will get you helpful replies." />

On to the sarcastic part of my message:

Since your assignment is "urgent" I dropped all my work to do it. Unfortunately, a Mongolian Horde chased my out of my lab and smashed my computer. So sorry...

Djaunla at 2007-7-10 11:13:48 > top of Java-index,Java Essentials,Java Programming...
# 3

Here's a start

class Person

{

// field here

// constructor here

}

class Car

{

// field here

// constructor here

// void newOwner(Person) here

}

Now fill in the details.

#

duckbilla at 2007-7-10 11:13:48 > top of Java-index,Java Essentials,Java Programming...