Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ENGAGE!

Name: Anonymous 2008-11-17 6:35

http://img.4chan.org/r9k/res/2156337.html

To be honest I felt kind of bad about it.

Name: Anonymous 2008-11-17 6:37

Are we this person's personal army?

Name: Anonymous 2008-11-17 12:39

File :1226917655.gif-(207 KB, 160x160, 1226189439920.gif)
207 KB Anonymous 11/17/08(Mon)05:27:35 No.2156337 

    My beloved /r9k/.

    I'm in desperate need of assistance with a Java program.
    I'm working with arrays, a method I need to create is supposed to take contents from one array(myPurse) and put them into another(yourPurse).

    I have a driver class, that's given by the teacher and I'm unable to modify, and here's its content for this method:
    // transfer all the coins from myPurse to yourPurse!
    Purse yourPurse = new Purse();
    yourPurse.addCoin(1);
    yourPurse.transfer(myPurse);
    System.out.println("\nnow myPurse contains: " + myPurse.toString());
    System.out.println("yourPurse contains: " + yourPurse.toString());

    Then in my real class I have to build up from the very basic:
    public void transfer(Purse donor)
    }
    {

    Any ideas?

>>    Anonymous 11/17/08(Mon)05:30:00 No.2156351

    Aww

    I want a bunny ;_;

>>    Anonymous 11/17/08(Mon)05:30:44 No.2156355

    >>2156351
    Omigod, me too! They're so cute. I want a cat more, though. I like cats, they're so fuzzy and lazy and cute.

>>    Anonymous 11/17/08(Mon)05:33:04 No.2156366

    >>2156355

    Fuck, I've been wanting a kitten for so long now. I have one cat, which I've had since the third grade, that was originally a barn cat so she's quite an evil motherfucker. I love her, but I want a kitten that I can hold onto and one that let's me pick it up and pet it and play with it.

    fffff

>>    Anonymous 11/17/08(Mon)05:33:11 No.2156368

    I may be able to sell you a bunny. First you have to solve this... uh.. mysterious puzzle posed by the OP. Who's totally not me, by the way.

>>    Anonymous 11/17/08(Mon)05:33:28 No.2156373

    for each i in myPurse
    yourPurse(i) = myPurse(i)

    Something like that.

>>    Anonymous 11/17/08(Mon)05:41:43 No.2156429

    >>2156368
    look, get out of the kitten thread, alright? Stop trying to derail this to be about programming.

    To stay ON TOPIC, I'm just going to leave this here:
    http://www.youtube.com/watch?v=bl2Bjc-qHAI&eurl=http://forum.frontrowcrew.com/comments.php?Discu
    ssionID=4151&page=3

>>    Anonymous 11/17/08(Mon)05:43:51 No.2156449

    >>2156373
    While it's quite possible that I'm just retarded, this doesn't seem to be working (a foreach loop, of course, not just copying and pasting exactly what you put in there).

>>    Anonymous 11/17/08(Mon)05:44:46 No.2156456

    >>2156429

    Oh hell. When the kitty is hanging off the side of the couch fffff SO CUTE

    God, why are furry little things so adorable?

>>    AUTONOMOUS !!LTxgdBIGAlX 11/17/08(Mon)05:46:18 No.2156473
     File :1226918778.jpg-(165 KB, 1280x850, IMG_3112.jpg)
165 KB

    Bunnies are the cutest.
    bunbunbunbunbunbunnnniiies

>>    Anonymous 11/17/08(Mon)05:46:58 No.2156477

    We need more info about the Purse class. Like, does each coin have the same value? What does the Purse toString return? etc.

    Also, it's not actually an array. An array is declared like Purse[].

>>    Anonymous 11/17/08(Mon)05:48:44 No.2156493

    >>2156473
    Floppy-eared bunnies are made of so much win.

>>    noko 11/17/08(Mon)05:49:25 No.2156498

    >>2156337

    Good on you OP taking my advice from earlier to ask r9k about this instead of b.

>>    Anonymous 11/17/08(Mon)05:52:07 No.2156510

    Pffffffffffffffff FOR loop that shit.

>>    Anonymous 11/17/08(Mon)05:54:49 No.2156520

    >>2156477
    There are 4 different kinds of coins, not labeled just given numerical values (1, 5, 10, 25). My MAX value is set to 10. In this exact instance I am to be dealing with the following coins: 5, 25, 10, 5, 1, but we're to consider that of course the code can be changed so that we can calculate any different assortment of coins.

    toString:
    {
    if (count == 0)
    return "()";

    StringBuffer s = new StringBuffer("(");
    int i = 0;
    for (i = 0; i < count - 1; ++i)
    s.append(contents[i] + ", ");
    s.append(contents[i] + ")");

    return s.toString();
    }
    Basically, returns: (coin1, coin2, coin3, coin4)
    You're right, I'm fairly retarded when it comes to Java.
    My array is contents[], which is storing the ints that represent the coin values. Another of my variables is count, which keeps track of the number of coins in contents[].

>>    Anonymous 11/17/08(Mon)05:55:46 No.2156526

    >>2156473
    fwoppy e-yuh'd bawnyyyyyyyyyyyyyyyyyy ;_;

>>    Anonymous 11/17/08(Mon)05:59:12 No.2156550

    >>2156510
    Somewhere along the line this is what I tried using:
    public void transfer(Purse donor)
    {
    for (int i = 0; i < count; ++i)
    result.append(yourPurse[i]);

    for (int i = 0; i < other.count; ++i)
    result.append(yourPurse[i]);

    }

    But I didn't get past compiling with that. "Cannot find symbol - variable yourPurse"

>>    Anonymous 11/17/08(Mon)06:01:47 No.2156568

    public void transfer(Purse donor)
    {
    for (int i=0; i<donor.count; i++) {
    this.addCoin(donor.contents[i]);
    donor.contents[i]=0; //or some other method to remove a coin from the purse
    }
    }

    That should do the trick.

>>    Anonymous 11/17/08(Mon)06:03:11 No.2156579

    >>2156550
    yourPurse doesn't exist in this context. Use donor instead.

>>    Anonymous 11/17/08(Mon)06:04:44 No.2156594

    >>2156568
    Oh my god you have no idea how much I love you. That worked. Perfectly.

>>    Anonymous 11/17/08(Mon)06:11:34 No.2156627

    >>2156594
    Cool. donor.contents[i]=0; isn't really ideal though. If Purse has a method like removeCoin(i) or emptyPurse() or something, you should use that instead.

    If you use donor.contents[i]=0; when you do ToString() you'll get something like "0 0 0 0".

>>    Anonymous 11/17/08(Mon)06:11:44 No.2156629

    Any computerfags feeling up for typing out an explanation about why the OP couldn't get this to work, and what someone else did to make it all happen correctly, to someone who knows absolutely nothing about coding?

    I'm kinda interested to know, but I have no previous knowledge.

>>    Anonymous 11/17/08(Mon)06:18:34 No.2156664

    >>2156629
    Well for starters, in OPs solution he had "result", "other", and "yourPurse", which were all undefined, therefore he got a compiler error.
    Also he was using append incorrectly - it's a method for Strings, not for Purses. Also there is no such thing as yourPurse[i] because yourPurse isn't an array.

    Of course most of that doesn't make sense if you don't already know anything about programming, but it might help OP.

>>    Anonymous 11/17/08(Mon)06:21:11 No.2156681

    >>2156664

    Yeah, that was pretty unhelpful to me, but I'm still appreciative. Actually, I think maybe that your first sentence makes sense to me.

>>    Anonymous 11/17/08(Mon)06:24:54 No.2156708

    >>2156681
    OP here.
    Basically, I was trying to change a value that didn't exist yet. (And to be fair, the other.count I accidentally posted here wasn't on my original code that the compiler spat back at me. I was looking at another bit of code for another program that did use other, and I got a bit mixed up)

    Moral of the story is: Pay good attention in your programming class, and if you're struggling, get yourself some help immediately. This stuff all snowballs.

    Fortunately, I've just got 4 weeks left.

>>    Anonymous 11/17/08(Mon)06:33:17 No.2156747

    ITT ENTERPRISE PROGRAMMARS

    SSSSSSSSSSSIIIIIIIIIIIIIIIIICCCCCCCCCCCCPPPPPPPPPPPPPPPP

>>    gjs !MhMRSATORI 11/17/08(Mon)06:51:28 No.2156851

    >>2156337
    http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-20.html#%_sec_3.1

>>    Anonymous 11/17/08(Mon)06:56:04 No.2156874

    >>2156681
    That function only has knowledge of the shit in the () which is a Purse named "donor".

    Dumbass here was trying to use the variable "yourPurse" which doesn't exist at all in that function.

>>    Anonymous 11/17/08(Mon)09:39:25 No.2157603
     File :1226932765.gif-(9 KB, 511x494, 1204379139607.gif)
9 KB

    lol java

>>    Anonymous 11/17/08(Mon)11:08:41 No.2158148
     File :1226938121.png-(1.27 MB, 942x1277, signed sicp.png)
1.27 MB

    jaev

>>    Anonymous 11/17/08(Mon)12:10:09 No.2158537
     File :1226941809.gif-(9 KB, 511x494, RELV.gif)
9 KB

    EXPERT PROGRAMMERS ITT.
    Please consider that the previous sentence was overlined, underlined, boldfaced, italicized, and typeset in Monafont.

Name: Anonymous 2009-08-17 0:23

Lain.

Name: Anonymous 2010-11-14 15:51

Name: Anonymous 2011-02-03 7:03

Don't change these.
Name: Email:
Entire Thread Thread List