Thank you very much sir, I was able to figure it out. The final thing I need to do is write the method for public void update(java.lang.String name, int quantity) but I think I can do it. I...
Type: Posts; User: EDale
Thank you very much sir, I was able to figure it out. The final thing I need to do is write the method for public void update(java.lang.String name, int quantity) but I think I can do it. I...
So p's toString() is being called and I'm assuming that's the one I want to print. But I think the toString is being printed from LineItem too... I was instructed to create a toString for LineItem to...
I realized by creating the collection in addToInvoice was creating a new collection every time addToInvoice is called. So I updated these two methods to:
public Invoice() {
...
Oh I see what you mean about not having an active console. It looks like to me yours output is right.. Could you guide me on what to do next?
--- Update ---
Okay I tried only doing one product...
--- Update ---
[/COLOR]I think the reason it is skipping position zero has something to do with this method:
public void addToInvoice(LineItem item) {
collection=new LineItem[5];...
The only import statements I was given to use are
import java.text.*; // for NumberFormat
import java.util.*; // for Locale
in the product class and
import java.util.Scanner;
The first position in the collection is giving me the null value.
I'm sorry, I don't quite understand everything in Java programming enough to figure out without a general example, and just...
Okay so for the last 3 spots giving null, I changed my method's for loop to only print as many items as I have put in by switching my code to
public void print() {
for (int i=0;...
The println() statement is printing the collection at all 5 positions. The last 3 positions have nothing in them so I think that's why I'm getting null. I don't know if I declared the array correctly...
Hey guys,
I'm working on arrays and I'm just not getting the hang of it. Every time my addToInvoice method is called and printed, it's not coming out correctly. Here's what the output is supposed to...