Win a copy of Rust Web Development this week in the Other Languages forum!

Timothy Stockdale

Greenhorn
+ Follow
since Sep 13, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Timothy Stockdale

And surprise, I'm back again. Sorry for asking so many basic questions guys, but my professor is not answering my calls or e-mails and the book is hardly helpful. This is my code.

I took Oliver's advice and created my arrays differently than before. I am a bit confused about why i needed a DVD class and a Stock class. I am not certain what each one does or which one should receive the set/get methods. I attempted using the set/get methods on my item number but it did not change the result of what my array displayed when it ran (which was gibberish). I actually thought the array held the information about the dvd's and that since the array had it stored, I could just use "System.out.println(stocks[0])" and that it would print out that line. I know that the "this" keyword in java is used mostly if a field is shadowed (although not entirely sure what that means), but as my thought process was that the information was stored in the arrays, I am not sure how or where to input the information so that the arrays display correctly. Also, my loop at the top was supposed to make the data display one line at a time. It is not shown, but I attempted to use Array.sort earlier and that failed miserably. What is the proper way to use that or am I going in the wrong direction? The array needs to be sorted by the name of the dvd.

Thanks in advance for the help everyone.
9 years ago
Thank you so much guys. I finally understand enough to make an array thanks to your example Oliver. I may be back before too long because I still have no idea about how to manipulate the array, but with it working correctly I might be able to figure it out.
9 years ago
I have become utterly lost and have scrapped my entire program that I posted. I am going back from scratch to try to get this fixed. This is my current code.

I know it is asking a lot, but can anyone walk me through this? My question at the moment is how do I get the Arrays that I have created (In the DVD class) to work in my Inventory Program class? I need them to display one at a time. Would I use the set and get feature? If so, how? If anyone can walk me through this one program, I may finally catch on.
9 years ago
In my original post I mentioned that the second part (which I hadn't posted yet) was due a few days ago. I am currently 3 days past due for this and have another part due this Sunday. I am going to post the entire requirement in advance. I have a strong feeling I'll be coming back to try to figure this out. For the moment, I am trying to sort my array by the name of the dvd's that I have entered, create a method to display the entire total of the inventory (the ProductValue displays the total inventory cost of each dvd, but I need the total inventory cost of the entire array), and I am supposed to have the entire program display the items one line at a time. So far I am failing at each of these. I will add comments for the parts that I am having trouble with.

I had thought maybe I could use a counter to keep track of the ProductValue, but I am not sure if that is possible. The next part is

"Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product you chose (for the DVDs subclass, you could use movie title, for example). In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class. The subclass method should also add a 5% restocking fee to the value of the inventory of that product.

Modify the output to display this additional feature you have chosen and the restocking fee."

That is due Sunday. Not asking you guys to do it for me, but I am probably going to have questions. I'll go back through the book chapters to see if I can find a clue. Probably looking like an idiot at the moment, but I could not be more lost when it comes to this.
9 years ago
I changed the code and kept getting the error until I actually tried to compile and run the code again. It worked after that. Thanks for the help on that part guys. The next is what is really got me lost. I am supposed to make it where my program now allows for multiple items using an array. This is the actual info on the assignment.

"Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory."

If I run into a snag I'll be right back here. You guys have been a big help so far. Thanks everyone.

PS: I just realized that the first part of the requirement (being able to handle multiple items) may already have been done. I added multiple items to my initial program when it only called for one. Am I misunderstanding this or would that be complete?
9 years ago
I tried what you guys suggested, but even changing the "Product" name to something else leaves me with the same error.
9 years ago
Desperately seeking help guys. I quite literally just started working with Java. I am in a Java class in college and am drowning. This is my code.

I keep getting a message saying that "The product class is already defined". Not sure what is wrong with it. I put this together from examples in the book and finding scraps of code online that dealt with classes using constructors. The instructor replies to questions with less than helpful information (If you are lost like I am at least), so please dumb the instructions down. Thanks guys, if I learn enough from you guys to pass this class I'll treat ya to steak .
9 years ago