954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DVDRentalSystem

Hey everyone and happy new year.

I'm a java beginner and I am doing my first program, a dvd rental system. I've got 4 classes with the following variables:

the main class
the dvd class - dvdID, title, rating, producer
the cleint class - cleintID, name, surname, address
the rentals class - clientID, dvd1, dvd2, dvd3

I need to know how to link the clientIDs. I am using arraylist.

JakeStanely
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

That looks like a mistake - the Rentals (Java classes conventionally begin with an upper case letter) class should have an instance of Client, not just a clientID (ie like the 3 DVD members).

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

I understand the part were I need to create a instance of the client class but what I don't know is how to create a relationship using the clientID.

JakeStanely
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

Forget about relational stuff. This is Object Oriented. You don't create a relationship using IDs, you have variables that contain direct to the objects themselves. Don't worry if this doesn't quite compute yet - it's a concept that sometimes takes a little time to grok, especially if you've just come from doing relational databases.
You get an instance of Client somehow, you get an instance of DVD somehow. You create an instance of Rental that has the Client and the DVD as its instance variables. The ID's play no part in that.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 
Forget about relational stuff. This is Object Oriented. You don't create a relationship using IDs, you have variables that contain direct to the objects themselves. Don't worry if this doesn't quite compute yet - it's a concept that sometimes takes a little time to grok, especially if you've just come from doing relational databases. You get an instance of Client somehow, you get an instance of DVD somehow. You create an instance of Rental that has the Client and the DVD as its instance variables. The ID's play no part in that.

Thanks alot. It helped me get to the solution I was seeing the problem form a different point.

JakeStanely
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: