Delta Virtual Airlines Water Cooler | PC Support |
Need URGENT help with JAVA |
DVA1933
Senior Captain, B727-200
Joined on September 19 2004
Triple Century Club
Monterrey, NL Mexico
357 legs, 860.4 hours
72 legs,
132.3 hours online 255 legs,
668.3 hours ACARS 1 legs,
1.9 hours event
|
Posted onPost created on
November 19 2007 11:21 ET by David Eugenio Gomez
|
OK guys, I know this is a little bit off-topic, but I know that we have some gifted programmers around here. I'm taking the Intermediate Programming course at college, in JAVA, and we've got the final project due on Friday.
I could use some help with the code since they didn't teach us what we need for the project in class. We have to use Object Composition (know it already) and Random Access Files (don't have experience using it) for this. Plus the logic is a little difficult for this one.
I will appreciate any help, I have the .java files already made, and I can email them to you if you choose to help (obviously, they are not finished yet). My design could be wrong though. Contact me via email please.
Here's what we have to do:
_________________
Videomax sells and rents video games. They require a solution that automatically handles or controls the sells and rents.
Especifically, they want to keep a record of the videos that are sold or rented, and those that can be sold. The store owns 20 videos at the beginning (20 and 20 tops).
A person can rent 10 videos at the most, and he has 5 days to give the rented videos back, or he will be charged with $50 pesos ($5 dollars).
It's necessary that a ticked is generated after every sell that they perform.
The system must have the Name, Phone #, Address, City, and RFC (some code) of each Customer that wants to perform an operation in order to generate the ticket.
Be aware that the inventory of available videos must be affected by each sell or rent generated by X customer.
__________
That's it, I'll appreciate any help!
|
DVA043
Senior Captain, MD-11
OLP
Joined on June 10 2001
Event Half Century Club
Online Double Century Club
50 State Club
DVA Twenty-Year Anniversary
Everett 1500 Club
Bi-Millennium Club
Four Million Mile Club
"Col. Panic" Marietta, GA
2,241 legs, 8,967.3 hours
240 legs,
553.9 hours online 1,899 legs,
7,760.4 hours ACARS 75 legs,
196.3 hours event 2,277 legs, 9,102.2 hours total 91 legs dispatched, 66.4
hours
|
Posted onPost created on
November 19 2007 11:24 ET by Luke Kolin
|
What specific problem are you running into?
Cheers!
Luke KolinSenior Captain, MD-11
|
|
DVA1933
Senior Captain, B727-200
Joined on September 19 2004
Triple Century Club
Monterrey, NL Mexico
357 legs, 860.4 hours
72 legs,
132.3 hours online 255 legs,
668.3 hours ACARS 1 legs,
1.9 hours event
|
Posted onPost created on
November 19 2007 11:34 ET by David Eugenio Gomez
|
Well, a few of them.
I simply don't know how to make the program "save" X number of Customers, in order to keep a record of what is X Customer renting. I thought of using a FileOutputStream C (customer) and ObjectOutputStream CX (Customer X), but I can't see it working that way.
I'm using a RandomAccessFile Inventory of 20 booleans, all of them at first defined as "true" meaning that the video is available, and every time a customer buys or rents X boolean, it should change to "false". This sounds logical to me, but when I run the program, and select any number of video to buy, the system defines X+1 as "false", and not the one I'm selecting.
Also, I thought of "saving" the Customer's selections in a "basket" using an array of X objects. This is supposed to be accomplished by usign a do{}while() and a counter. Something like basket[counter] in order to display the ticket with the videos he got in the end.
|
DVA043
Senior Captain, MD-11
OLP
Joined on June 10 2001
Event Half Century Club
Online Double Century Club
50 State Club
DVA Twenty-Year Anniversary
Everett 1500 Club
Bi-Millennium Club
Four Million Mile Club
"Col. Panic" Marietta, GA
2,241 legs, 8,967.3 hours
240 legs,
553.9 hours online 1,899 legs,
7,760.4 hours ACARS 75 legs,
196.3 hours event 2,277 legs, 9,102.2 hours total 91 legs dispatched, 66.4
hours
|
Posted onPost created on
November 19 2007 12:58 ET by Luke Kolin
|
If you were doing this in a database it would be really easy, but we can still use some of the same principles.
First, you'll want a separate file for customers and videos, and a third for transactions. Each record in a file maps to a Customer, Video, or Transaction object. Each has a unqiue ID. The transaction object will simple store the customer ID, video ID, rental and return dates, and fees for each video. If a video is sold, then we have a flag in there fore that as well. Each time you do a a transaction, you write an entry there. To determine if a video is available, you'll need to iterate through all of the transactions to see if it has been rented and not returned, or if it has been sold.
Does that help?
Cheers!
Luke KolinSenior Captain, MD-11
|
|
DVA1933
Senior Captain, B727-200
Joined on September 19 2004
Triple Century Club
Monterrey, NL Mexico
357 legs, 860.4 hours
72 legs,
132.3 hours online 255 legs,
668.3 hours ACARS 1 legs,
1.9 hours event
|
Posted onPost created on
November 19 2007 13:19 ET by David Eugenio Gomez
|
Thanks Luke, it does help.
But then we have a problem, how do you save objects in a RandomAccessFile? As far as I know, you can only save byte, double, char, boolean and int in a Random file.
I could use an ObjectOutputStream, but then I could not modify that file.
|
DVA1933
Senior Captain, B727-200
Joined on September 19 2004
Triple Century Club
Monterrey, NL Mexico
357 legs, 860.4 hours
72 legs,
132.3 hours online 255 legs,
668.3 hours ACARS 1 legs,
1.9 hours event
|
Posted onPost created on
November 19 2007 20:23 ET by David Eugenio Gomez
|
OK, I managed to finish 80% of the project this afternoon. Followed your advice on creating records for every customer, his data is in a OutputStream File, while the stuff he's rented or bought is in a RandomAccess File.
I think I've got it from here. Thanks Luke. I'll send you a copy when it's finished LOL.
|