Search:

Type: Posts; User: jps

Search: Search took 0.08 seconds.

  1. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    When a sale is made, you will have to sell a specific quantity. When you get a Transaction from the list, it may or may not have enough quantity to cover the sale. In the easy case, the sale is the...
  2. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    How will the new version of the sell method look then?
    Here is some reading on nested classes
  3. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    The instructions said:
    Any extra classes that you write should be included as
    private nested classes. Any additional class methods should also be private.
    So be sure to follow that guideline
  4. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    In the current design you have two array lists.
    Stocks.add(stock);
    StockPrice.add(price);

    In the proposed setup, you have only one list, and add items as such:
    Stocks.add(new...
  5. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Something like that should work, ya. This way you end up with a single unit to store in the queue, and an easy way to get the purchasePrice associated with each purchase on an individual basis, and...
  6. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Creating a data type (new class) to store the data is much better practice than trying to maintain two different array lists in sync. What would happen if one list did not get updated?...Both lists...
  7. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    The instructions are not clear that the first purchased are to be the first sold or not, so that could be up for debate.
    So it seems to me I would make a class to represent a transaction, and store...
  8. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Can you post the instructions, I want to be sure I fully understand what should be done
  9. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    No the method name does not change the result, it is just convention to have variable names describe the value they hold, and method names describe their purpose. It is in an attempt to make the code...
  10. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Be sure to use code tags when posting code, help can be found on the announcements page
    public int sell(int x, int y)
    x and y are poor variable names, they should describe the value they represent...
  11. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    ...and the code you have so far?
    ..so we have a starting point, I can not just write the code for you :)
  12. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Write out the math here and I will help you translate it into code
  13. Replies
    25
    Views
    3,178

    Re: Array List implementation(Buying and selling)

    Use a class to store the item and the price.
    What is it you are having problems with? working out the math or writing the code that performs the math?
Results 1 to 13 of 13