Results 1 to 10 of 10
  1. #1
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default Final project - last part, selling a stock

    assignment turned in, completed. thank you for all the help throughout the quarter. until next quarter!
    mods feel free to lock thread.
    Last edited by hiei_yasha; 03-12-2011 at 07:00 AM. Reason: problem solved

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default

    how does selling a stock work/ what approach could i take to solve it?
    i know it's not just the opposite of buying a new stock, since i have to account the subtraction and displaying the result

    for example if i choose
    Microsoft
    MSFT
    123.45
    805

    the result will be
    Microsoft
    MSFT
    123.45
    1 (since 806-805=1)
    Last edited by hiei_yasha; 03-12-2011 at 03:07 AM.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    if all shares are sold, then the stock won't be printed if user chooses to print the information to the screen.

    Is that the problem? If so, note that there will be nothing printed in that case because there is nothing to print.

    Java Code:
    public static void printStocks(String filename, ArrayList<Stock> myList)
    {	
    	for (Stock s: myList)
    		System.out.println(s.toString());
    }//end printOutStocks

    If you want something to print if myList is empty, test for that and print something.

    Or is something else the problem? Does sellStock() do what you expect? If not, what does it do and what were you expecting?

  5. #5
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default

    at the moment sellStock doesn't do anything. get the same output regardless of what i enter.

    that's correct that if all shares are sold, the company's information won't be printed

  6. #6
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default

    so i've come up with something that works, slightly off though

    The only problem is if i decide to sell from a company that isn't at index 0 (so google in this case), it'll print "Company not found" since google =/= microsoft, but it will still subtract correctly and print out correctly when i prompt it to.
    Last edited by hiei_yasha; 03-12-2011 at 06:59 AM.

  7. #7
    Clerek is offline Member
    Join Date
    Jan 2011
    Posts
    20
    Rep Power
    0

    Default

    Hey man,
    I though stu just wanted to change the size of the arraylist, not decrease the shares that we have...

    For example, the assignment says:
    6. Sell a stock decrease the size of the ArrayList required. You will not have an ArrayList that is too large.

    All he wants us to do is decrease the size of the ArrayList. No need for all the extra work...

  8. #8
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default

    no, there was a series of emails floating around that said:

    "According to Stu - the sell stock method must handle the cases of selling a user defined amount of stock and removing an entity if all the stock is sold. "

    "
    Need to handle both

    Stu"

    "I assume that when a stock is sold, you are asking us to delete the entire element within the list. I assumed so because the instructions say to decrease the size. Many students are thinking that they need to subtract a certain number of shares from a company."

    so we need to sell the stock of an existing stock or one that we made/"bought".
    for microsoft, if we decide to sell 800 shares, it'll print 6 shares.
    if the number of shares = 0, ie we sell all 806 in microsoft, it must not print out when we select to print it
    Last edited by hiei_yasha; 03-12-2011 at 06:27 AM.

  9. #9
    Clerek is offline Member
    Join Date
    Jan 2011
    Posts
    20
    Rep Power
    0

    Default

    Wow seriously? I just finished an was about to submit...

  10. #10
    hiei_yasha is offline Member
    Join Date
    Jan 2011
    Posts
    34
    Rep Power
    0

    Default

    yup. i think sellstocks gave people the most problems
    Last edited by hiei_yasha; 03-12-2011 at 06:53 AM.

Similar Threads

  1. Urgent! Need help for my final year project!!
    By kazuma_riku73 in forum Sun Java Wireless Toolkit
    Replies: 7
    Last Post: 06-18-2010, 11:48 AM
  2. Final year project idea -
    By nadia in forum Advanced Java
    Replies: 11
    Last Post: 10-28-2009, 01:22 PM
  3. Urgent! Need help for my final year project!!
    By kazuma_riku73 in forum Sun Java Wireless Toolkit
    Replies: 1
    Last Post: 01-15-2009, 11:14 AM
  4. GUI Final Project help
    By Unknown in forum New To Java
    Replies: 21
    Last Post: 12-30-2008, 07:58 PM
  5. help to complete final part of project
    By dirtycash in forum New To Java
    Replies: 6
    Last Post: 12-31-2007, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •