Search:

Type: Posts; User: ralf

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I 'm about to write a code to print all details...

    I 'm about to write a code to print all details of product below an inserted value
    What is most correct, write a new method to do it or write a method which call another print method that allready...
  2. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I have done it. Its works

    I have done it. Its works
  3. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Hello, Could someone tell me how I can call to...

    Hello,
    Could someone tell me how I can call to a method which is a void method in another class?
  4. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Yes, it compile and execute and give the result...

    Yes, it compile and execute and give the result that I want
    does it code look correct? It should be correct now
  5. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I have tested the code in a debugger an I can...

    I have tested the code in a debugger an I can see that the correct return is returned. So I think this method work well now.
    Thank for your help again Norman!
  6. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Could you please tell me if this look correct...

    Could you please tell me if this look correct
    When I use the print out, it print correct number. If write number 2 in the parameter, it print "not a valid number" since there don't exist anything...
  7. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I'm trying to return quantity in the item in...

    I'm trying to return quantity in the item in stock, but when I insert a number which I know not exist then I get a nullpointer




    if(findProduct(id).getID() != id) or...
  8. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I have tryed this one, but it don't work ...

    I have tryed this one, but it don't work




    if(findProduct(id).getID() != id) or (findProduct(id).getQuantity() == 0)
  9. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I'm stuck on this method numberInStock Any idea...

    I'm stuck on this method numberInStock
    Any idea on how I should do the test for 0?
    should I use an if test inn an if test?
  10. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    The findProduct() return this when there are no...

    The findProduct() return this when there are no items with that number

    java.lang.NullPointerException
    at StockManager.numberInStock(StockManager.java:124)

    I try to use an if test stop the...
  11. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    It seems to work at least when I'm insert a...

    It seems to work at least when I'm insert a number into the parameter, a number I know exist in the list of quantity, but if I insert a number which there are no items with that number, then I get:
    ...
  12. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Hello, Norm! I think this short code actually...

    Hello, Norm!

    I think this short code actually is sufficient for the task to find quantity
    It is only the return line that is needed.
    The next method that I'm about to do is a method to incresae...
  13. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I have this method which print out details With...

    I have this method which print out details
    With this output:
    Product: 23: Microwave Oven stock level: 0
    Product: 23: Microwave Oven stock level: 0
    Product: 23: Microwave Oven stock level: 0...
  14. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    I'm not shore if I understand you correct, but is...

    I'm not shore if I understand you correct, but is it something like this for loop?
    The output from the code below:

    Quantity :0

    ID :37
    Quantity :0

    ID :37
    Quantity :0
  15. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    This is the constructor in the class Product,...

    This is the constructor in the class Product, where quantity is set to 0. This is the value I get returned when I use the method numberInStock and not the number of items which are stored in stock...
  16. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    This code is where the item is being added: I add...

    This code is where the item is being added: I add it like this: (new Product(132, "Clock Radio")) and if I add the same line two or more times, then I think the quantity should keep a record on how...
  17. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    This is what I have tryed so far The output:...

    This is what I have tryed so far

    The output:
    1: Quantity 0// print 0 even there are two item with id number 132
    1: ID 132
    2: Quantity 0
    2: ID 132
  18. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Any idea what I'm doing wrong?

    Any idea what I'm doing wrong?
  19. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Hello, I can compile and run it, but only 0 is...

    Hello,

    I can compile and run it, but only 0 is returned.
    getQuantity(); should return an int of how many items there are in stock.
    When a use a debugger I can see that when it come to...
  20. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Could you tell me if I am a bit closer to a...

    Could you tell me if I am a bit closer to a correct code now?



    public int numberInStock(int id)
    {
    if(id < 0)
    {
    System.out.println("Not a valid id " + id);
    ...
  21. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Hello, Could you give me some hint? I have...

    Hello,

    Could you give me some hint? I have tryed a lot of several version, but nothing seems to be correct
    Product product = Product getQuantitiy(); etc
  22. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    findProduct(); is a method in the class...

    findProduct(); is a method in the class StockManager. I have now written: findProduct(id); I think that one can be right intsead of product.findProduct();

    Class Product contain id, product name...
  23. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    Do I need to use casting? I have tryed this:...

    Do I need to use casting?

    I have tryed this: Product product = (Product) product.findProduct(); // something like this?
  24. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    In this method I have called to the method...

    In this method I have called to the method getMonth() in class membership.


    public int joinedInMonth(int month)
    {
    int count = 0;
    if(month < 1 || month > 12)
    {
    ...
  25. Thread: Method call

    by ralf
    Replies
    51
    Views
    6,639

    That is the problem I have now, How I can call...

    That is the problem I have now, How I can call from method numberInStock to findProduct method and then get the result from getQuantity?


    public int numberInstock(int id)
    {
    //do a call to...
Results 1 to 25 of 28
Page 1 of 2 1 2