Page 2 of 12 FirstFirst 1234567891011 ... LastLast
Results 31 to 60 of 356

Thread: ProgrammersitP

  1. - Top - End - #31
    Ettin in the Playground
     
    Recaiden's Avatar

    Join Date
    Apr 2008
    Location
    The Icy Northlands
    Gender
    Intersex

    Default Re: ProgrammersitP

    Part time work programming for a small company, and studying Computer Science in college.

    This has me working with C#, Javascript, and C at school, and C++ at work. But previously there was actionscript and Python to deal with too. Python is easily my favorite. I never have to fight with the language to get things done.

    Mainly waiting. I like programming, but not as much as other things. It's just at an intersection of being good, getting me a job and not being disliked.

    I had a project to do with music composition, but since going back to school
    I haven't been able to work on it. Programming actually depresses me a bit.

    I prefer QtCreator, but it's only good for a few types of project. Mainly it's Emacs and the command line.
    ~Inner Circle~
    Spoiler
    Show


    Quote Originally Posted by Raz_Fox View Post
    He takes normality and reason and turns them UP TO 11!
    Echidna by Serpentine - But I also make avatars

  2. - Top - End - #32
    Ogre in the Playground
     
    Reinboom's Avatar

    Join Date
    Mar 2007
    Location
    Santa Monica, CA, US
    Gender
    Female

    Default Re: ProgrammersitP

    Where are you and what are you doing in terms of programming? Employment, education or in your spare time?

    I'm a software engineer at a video game company. I'm a college dropout (I went for Animation, anyways :P ), and my spare time programming tends to be focused on game utilities of some sort. I don't do much anymore in terms of self interest programming however.

    What language or languages are you using primarily at the moment? What's your favourite, and why?

    Primarily I use ActionScript 3 (note: Scaleform, not for Flash games) as of late, and C++ secondarily. Other languages in use: JavaScript (Node.js), Ruby (mostly build scripts), C# (Tools), PHP (Symfony2 small end apps), and quite a few others crop up at times (Erlang, Python, Java, and more).

    My favorite language, as a language in of itself, is ActionScript 3. Being able to pass loose Objects around while still having hard types. A syntax that partially self documents. Annotations as a language feature. Interfaces as a language feature. Regular expressions having an in language syntax. External code interface that's simple and to the point. A strong standard library that can keep out of the way when you don't want it. Graphics as an assumption instead of an afterthought.

    However, I hate the "standard compiler". Flash as a dependency is annoying. Especially for my work flow (we don't use AS3 for Flash purposes).


    Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?

    My programming work is my living, and my fun. I've already settled on my career, though I might transition slightly away from it in time, depending.


    Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?

    At work: Many. At home: I'm building a JavaScript CAS, but otherwise... nothing.


    What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?

    Depends.
    ActionScript 3: FlashDevelop (+... Flash Professional for creating timelines / a graphics bucket. :/ )
    C++: visual studio + a bunch of other things to make it less visual studio
    Everything else: Notepad++ or vim


    Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?

    Uh... legacy code that's written to be unreadable and not well commented is about all that angers me in coding anymore. That's where the most expensive and annoying tech dept arises.


    Edit:
    Oh, and floating point errors. Floating point errors are annoying.
    Last edited by Reinboom; 2012-09-08 at 07:10 PM.
    Avatar by Alarra

  3. - Top - End - #33
    Barbarian in the Playground
     
    Miscast_Mage's Avatar

    Join Date
    Dec 2010
    Location
    Ireland
    Gender
    Male

    Default Re: ProgrammersitP

    So, I've been working on understanding 2D arrays, and in particular higher dimensional arrays, but is there any practical application to higher dimensional arrays(that go beyond 2D/3D)?

    Say, with 2D arrays, I could have a list of classrooms that contains students. If I make it a 3D array, I could have a list of schools, which each have a list of classrooms, which each have a list of students. The only problem with that is, is that the classroom/school is only a list, not an object in of itself, so I can't see how you'd apply any data to anything other than the student class.

    Would arraylists or collections be better suited for something like this, or something else all together?

  4. - Top - End - #34
    Ettin in the Playground
     
    Teddy's Avatar

    Join Date
    Mar 2009
    Location
    Sweden
    Gender
    Male

    Default Re: ProgrammersitP

    Depending on your programming language, objects, structs or tuples all provides means of storing information in the intermediate layers of an array.

    And yes, multiple dimension arrays quickly lose any rational applicability after the first 2 or 3 dimensions. You can certainly find some use for them, but the 100-dimensional array is probably just built for laughs anyway (and on top of that, it's a terrible memory hog, filling up 4MB worth of memory just with memory adresses (assuming a 32 bit system))
    I'm doing a Tour de Friends! Please drop by and tell me if you're interested in having me drop by for a visit this summer!

    Clouddreamer Teddy by me, high above the world, far beyond its matters...

    Spoiler: Banner by Vrythas
    Show

  5. - Top - End - #35
    Barbarian in the Playground
     
    shawnhcorey's Avatar

    Join Date
    Dec 2010
    Location
    The Great White North
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    Would arraylists or collections be better suited for something like this, or something else all together?
    Yes, definitely. The language you're using influences what would be the best solution. Some languages come with an associated list, which makes problems like this easy. What language are you using?
    How do you keep a fool busy? Turn upside down for answer.
    ˙ɹǝʍsuɐ ɹoɟ uʍop ǝpısdn uɹnʇ ¿ʎsnq ןooɟ ɐ dǝǝʞ noʎ op ʍoɥ

  6. - Top - End - #36
    Ogre in the Playground
     
    Neftren's Avatar

    Join Date
    Nov 2006

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    So, I've been working on understanding 2D arrays, and in particular higher dimensional arrays, but is there any practical application to higher dimensional arrays(that go beyond 2D/3D)?

    Say, with 2D arrays, I could have a list of classrooms that contains students. If I make it a 3D array, I could have a list of schools, which each have a list of classrooms, which each have a list of students. The only problem with that is, is that the classroom/school is only a list, not an object in of itself, so I can't see how you'd apply any data to anything other than the student class.

    Would arraylists or collections be better suited for something like this, or something else all together?
    As Teddy pointed out, the choice of language heavily influences your data structure. In the case of C/C++, it might make more sense to have a map with key/pair combinations of classrooms and student listings (as opposed to nesting arrays). Also, data doesn't necessarily need to be kept in your own instantiated "objects" or such. You can freely put lists inside vectors, and so on... I'm not quite sure what the Java equivalent is though. I haven't touched it in a few years.

    As for answering your question, computation bounds are typically no more than four dimensions (x, y, z, t), at least in a physics or scientific computation sense. For the most part, it might even be just three dimensions (x, y, z) and you iteratively solve the problem by computing the solution at each time step, using the solution from the previous time step (see: difference equations).

  7. - Top - End - #37
    Ettin in the Playground
     
    pendell's Avatar

    Join Date
    Dec 2006
    Location
    Washington DC
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    So, I've been working on understanding 2D arrays, and in particular higher dimensional arrays, but is there any practical application to higher dimensional arrays(that go beyond 2D/3D)?

    Say, with 2D arrays, I could have a list of classrooms that contains students. If I make it a 3D array, I could have a list of schools, which each have a list of classrooms, which each have a list of students. The only problem with that is, is that the classroom/school is only a list, not an object in of itself, so I can't see how you'd apply any data to anything other than the student class.

    Would arraylists or collections be better suited for something like this, or something else all together?
    In my experience (18 years of it), I have never needed an array bigger than 2D.

    When you're storing a list of schools with classrooms, it's better to delve into object-oriented programming and define a class of schools thus:

    Class Student {
    Integer id;
    String name;
    Date dateOfBirth;
    // etc.
    }

    Class Classroom {
    Integer roomNumber;
    Student[] studentsInClass;
    }

    Class School {

    String schoolName;
    Classroom[] classes;
    }

    Of course, this is a very simple way to do it. If you're working with a data table you might do something like this:

    School {
    Integer id;
    String schoolName;
    }

    ClassRoom {
    Integer id;
    Integer schoolId ; // Foreign Key to School-> ID;
    }

    Student {
    Integer id;
    Integer[] classIds; // foreign keys to classrooms
    Integer schoolId; // foreign key to school.
    }


    The advantage of an approach like this is you can use it in conjunction with software such as hibernate to quickly drop it into a mysql database.

    SO: Fundamentally I have no need for 3D or 4D arrays. It is almost always better to have a 1D array or list or collection of a data structure such as a pascal record or a c struct

    But better than either of those are object-oriented classes such as those defined in python . Partly because they're more common, but also because they mask a lot of complexity. The ability to attach methods doesn't hurt either.

    IME, higher-dimensional arrays are only really necessary if you're running a very high performance application (global climate modeling, say) and you can't afford the overhead of object-oriented programming. But that is quite uncommon.

    Respectfully,

    Brian P.
    "Opportunities to do good are everywhere but the darkness is where the light needs to be".

    -- Eliezer Yudkowski, author of "Harry Potter and the Methods of Rationality"

  8. - Top - End - #38
    Ettin in the Playground
     
    nedz's Avatar

    Join Date
    Apr 2010
    Location
    London
    Gender
    Male

    Default Re: ProgrammersitP

    Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    I have a BSc in Computer Science and Mathematics.
    I'm a free lance software engineer with 26 years of commercial experience, currently between contracts.

    What language or languages are you using primarily at the moment? What's your favourite, and why?
    I normally write Windows C++, but have done all sorts of things. I managed to pick up some Java and C# experience on my last contract, using Netbeans and Eclipse. I tend to be systems orientated, usually working at the framework level; I'm a pretty experienced assembler programmer for instance.

    Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    My last two contracts were as a performance analyst/trouble-shooter, which generally seems to imply that the architect screwed up. I might want to do something else next.

    Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    I have recently downloaded the Android SDK, but haven't done anything with it yet. I did have an image processing idea, which I ought to do some work on.

    What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    I don't like CVS or command line interfaces, but I can use anything.

    Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
    Resolving this issues is what I get paid for, and thankfully enjoy.
    Last edited by nedz; 2012-09-16 at 10:36 AM.
    p = 4
    Consider a 5' radius blast: this affects 4 squares which have a circumference of 40' — Actually it's worse than that.


    Completely Dysfunctional Handbook

    Avatar by Caravaggio

  9. - Top - End - #39
    Barbarian in the Playground
     
    Capt Spanner's Avatar

    Join Date
    Feb 2010
    Location
    UK
    Gender
    Male

    Default Re: ProgrammersitP

    I guess I should tip my hand.
    • Where are you and what are you doing in terms of programming? Employment, education or in your spare time?

      I had some modules in computational modelling while doing my physics degree. I then did an MSc. in Game Software Development and now work for Sony Computer Entertainment Europe in the R&D department.
    • What language or languages are you using primarily at the moment? What's your favourite, and why?

      We use C++, with the odd bit of Lua. I've never touched the Lua side. I'm also adept in Python.
    • Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?

      I'm happy where I am. Working for Sony has a lot of benefits. I may look into getting into an actual game studio later in my career.
    • Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?

      I recently finished a procedural racetrack creator for TORCS. I'll next be looking to create a racing team manager game, where procedurally generating tracks will be very handy.
    • What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?

      Microsoft Visual Studio is a pretty tight environment. I want to upgrade to VS1012 soon, as it has loads of the C++11 features.
    • Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?

      Linker errors. They are always really obscure. I also hate naked pointers.

  10. - Top - End - #40
    Barbarian in the Playground
     
    BarbarianGuy

    Join Date
    Feb 2010
    Location
    Calgary
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    [*]Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    I have taken some programming courses in the past. Used some of it in my last job. Now that I am unemployed I have decided to go back to university and get a Computer Science degree.

    Quote Originally Posted by Miscast_Mage View Post
    [*]What language or languages are you using primarily at the moment? What's your favourite, and why?
    At work I had written some programms in Awk, C, and C++. The courses in the past we studied c, I studied some C++ on my own. My current cpsc course we are using python, my next cpsc course we will use java (created at my University no less :) ) Don't have vast experience with many languages yet. So far I guiess c/c++ is my favorite since I know it the best so far. Python does have some cool features though.

    Quote Originally Posted by Miscast_Mage View Post
    [*]Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    Graduate with a Bsc in Computer science in 3 to 4 years. Then either get back out there looking for work or think about getting a masters.

    Quote Originally Posted by Miscast_Mage View Post
    [*]Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    Nothing except school assignments right now.

    Quote Originally Posted by Miscast_Mage View Post
    [*]What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    Well I use to own the old Borland c++ 4.5, I have tried both eclipse ond code blocks. Currently I just type in pico.

    Quote Originally Posted by Miscast_Mage View Post
    [*]Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
    Not right now years ago in one of my first programming courses there was this one assignment I just couldn't get to run. I tried and tried but nada. I asked the instructor just to give me a zero (lowest mark on assignments was dropped) he said he couldn't do that till I handed in a working copy of the program. I got fed up and just asked another student if I could look at his code (this is like 3 months past it's deadline)

  11. - Top - End - #41
    Ogre in the Playground
     
    Thajocoth's Avatar

    Join Date
    Mar 2009
    Location
    Campbell CA
    Gender
    Male

    Default Re: ProgrammersitP

    • Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
      -I'm a full time employee in the video game industry.
    • What language or languages are you using primarily at the moment? What's your favourite, and why?
      -I'm using C. My favorite is C++ with a C leaning.
    • Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
      -I've fulfilled all my goals... I need to come up with new ones.
    • Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
      -Yes. I'm in the middle of several professional projects.
    • What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
      -Microsoft Visual Studio
    • Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
      -The code base I'm in is kinda old, so there's code here & there that's not written well, or is confusing, but nothing seems to be in my way. The most annoying thing for me, honestly, is that I had gotten used to '}' causing automatic indentation of the block I'm closing, and Microsoft Visual Studio only has this option for C#, not for C.
    Last edited by Thajocoth; 2012-09-19 at 04:58 PM.
    Avatar by me. It's Incendius Darkscale, a Good Dragonborn Dragon Sorcerer, Demonskin Adept, Prince of Hell, worshiper of the Platinum Dragon (Bahamut), specializing in Fire and Lightning, wielding a staff in each hand.

  12. - Top - End - #42
    Barbarian in the Playground
     
    Capt Spanner's Avatar

    Join Date
    Feb 2010
    Location
    UK
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Lensman View Post
    Sorry - reads like I was ranting. Actually, I was. Anyone got an alternative to Visual Studio that a dumb amateur programmer can cope with?
    Visual Studio can really help you programming. It's actually quite easy to use - just write the code and press the green button.

    It can ever create boilerplate code for you.

  13. - Top - End - #43
    Ogre in the Playground
     
    Neftren's Avatar

    Join Date
    Nov 2006

    Default Re: ProgrammersitP

    Quote Originally Posted by Capt Spanner View Post
    Visual Studio can really help you programming. It's actually quite easy to use - just write the code and press the green button.

    It can ever create boilerplate code for you.
    Visual Studio does have its share of frustrations though. I spent two hours trying to figure out why my Rabin-Karp hash was failing in Visual Studio, when it compiled just fine under gcc 4.2 in OSX.

    That, and I actually need to go get a copy now that I think about it. Just so I can compile in Windows when people ask me...

    (or maybe I'll just install MinGW or something)
    Last edited by Neftren; 2012-09-19 at 04:47 PM.

  14. - Top - End - #44
    Barbarian in the Playground
     
    Capt Spanner's Avatar

    Join Date
    Feb 2010
    Location
    UK
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Neftren View Post
    Visual Studio does have its share of frustrations though. I spent two hours trying to figure out why my Rabin-Karp hash was failing in Visual Studio, when it compiled just fine under gcc 4.2 in OSX.
    Getting stuff to compile cross platform is a programming frustration - not a problem with any particular environment.

  15. - Top - End - #45
    Barbarian in the Playground
     
    shawnhcorey's Avatar

    Join Date
    Dec 2010
    Location
    The Great White North
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Capt Spanner View Post
    Getting stuff to compile cross platform is a programming frustration - not a problem with any particular environment.
    Getting stuff to compile cross platform should only be a problem for the I/O portions. Everything else should compile and work.
    How do you keep a fool busy? Turn upside down for answer.
    ˙ɹǝʍsuɐ ɹoɟ uʍop ǝpısdn uɹnʇ ¿ʎsnq ןooɟ ɐ dǝǝʞ noʎ op ʍoɥ

  16. - Top - End - #46
    Dwarf in the Playground
     
    Drumbum42's Avatar

    Join Date
    Jul 2005

    Default Re: ProgrammersitP

    Where are you and what are you doing in terms of programming? Employment, education or in your spare time? Got a BS in CompSci but currently I'm working as a network admin. Not exactly what I pictured doing, but I enjoy it so.... close enough.

    What language or languages are you using primarily at the moment? What's your favourite, and why? Well primarily I'm using Java and SQL (yes I know it's a query language) for network tools and database management.

    Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along? Planning on moving to programming in the future, but I enjoy my current job, so no rush.

    Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on? I programmed a 1e AD&D combat simulator to find out how powerful characters ACTUALLY are. Then I ran into the problem of having more then 8v1 at a time. In a box grid the 9th person would have to wait for his friend to die, then move into his spot. I stopped when I realized it would be weeks of work to add agency to my software. I called it a victory and moved on.

    What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor? Eclipse and command line. Often both at the same time for networking applications.

    Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code? Nope, currently just slowly plodding along with my multi-server C&C application. Only code in my spare time at the moment.

    Also I have used munti-dimentional arrays (more then 3). Though very rarely. Mostly it was to keep big programs from getting really slow or holding multiple spreadsheets of data. (For access speed arrays are the way to go. Seek time? 1. But for sorting, terrible.) And I would assume that older languages need these too as objects/linked lists/array lists don't exist.

    Proud 1st edtion player!
    me love thog
    High Priest of Banjo

  17. - Top - End - #47
    Barbarian in the Playground
     
    Miscast_Mage's Avatar

    Join Date
    Dec 2010
    Location
    Ireland
    Gender
    Male

    Default Re: ProgrammersitP

    So, I've been having a bit of a problem with arraylists here(working in Java):

    I've been working on a program to generate a deck of cards, each unique, e.g. [spades][5], [clubs][A], etc. I wanted to use an arraylist, because I can then use the collections shuffle to easily randomise the positions of the card in the deck.


    Here's a slightly barebones version of the code:

    Spoiler
    Show

    Code:
    import java.util.ArrayList;
    
    public class Card 
    {
        static String suit;
        static String number;
        
        void printCard() //print outs card.
        {
            System.out.println("Suit is: [" + suit + "] and number is: [" + number + "]");
        }
        
        static void deckGenerator()
        {
            ArrayList<Card> deck = new ArrayList<>();
            Card test = new Card(); //only one object created; I think this is the problem.
            
            for(int i = 0; i < 4; i++) //outer for loop, gets the suit of the card.
            {
                
                switch(i)
                {
                    case 0:
                        suit = "Spades";
                        break;
                    case 1:
                        suit = "Hearts";
                        break;
                    case 2:
                        suit = "Clubs";
                        break;
                    case 3:
                        suit = "Diamonds";
                        break;
                }
                
                
                for(int x = 1; x < 14; x++) //inner for loop, gets the number of the card.
                {
                    
                    switch(x)
                    {
                        case 1:
                            number = "A";
                            break;
                        case 11:
                            number = "Q";
                            break;
                        case 12:
                            number = "J";
                            break;
                        case 13:
                            number = "K";
                            break;
                        default:
                            number = (Integer.toString(x));
                            break;    
                    }
                    deck.add(test);//adds the card to the deck.
                    //if I put the test.printCard() here, it prints each card with their own value.
                }//end of inner for loop
            }//end of outer for loop
            
                for(Card meow : deck) //test for-each loop. Prints the same value each time.
                {
                    test.printCard();
                }
        }
        
        
    }
    The output when I have the for-each loop where it is is:
    Code:
    Suit is: [Diamonds] and number is: [K]
    Suit is: [Diamonds] and number is: [K]
    Suit is: [Diamonds] and number is: [K]
    ...
    etc, for 52(4 x 13) loops.
    The output when I have the print method inside the inner for-loop:
    Code:
    Suit is: [Spades] and number is: [A]
    Suit is: [Spades] and number is: [2]
    ...
    Suit is: [Hearts] and number is: [5]
    Suit is: [Hearts] and number is: [6]
    ...
    Suit is: [Clubs] and number is: [Q]
    Suit is: [Clubs] and number is: [K]
    ...
    etc, for 52(4 x 13) loops, but each card value is correct.


    Now, the problem I'm having is that having the for-each loop to print each card where it is(outside of the for loops) just prints back [diamonds][K] for as many cards in the array.
    But if I put the print statement in the inner for loop, it gives back each card as it's own value, e.g. [spades][5], [clubs][A], etc.

    I think the cause of the problem is that I'm only creating the one object, and using that for each card in the arraylist. So I'm writing new values to the card each time, and putting it in the arraylist, but this just changes all the previous cards values as well, which isn't what I want.

    I don't know how to create a unique card object for each time a suit and number is applied. Is there a way to do this, that I can later reference/use specific cards that I want? Maybe have an ID variable for each card? Thanks and appreciation for any help that can be offered.

  18. - Top - End - #48
    Ettin in the Playground
     
    Teddy's Avatar

    Join Date
    Mar 2009
    Location
    Sweden
    Gender
    Male

    Default Re: ProgrammersitP

    You're right in your analysis that you create just one card and then modify the value of it. The reason for why it prints out correctly inside the inner loop is because you only print out the last card each time. If you were to print them all out each time, you'd see that they all have the same colour and value in any given iteration of the loop(s).

    The solution is simply to declare 52 different Card objects, which is easiest done inside the loop. I suggest the following changes: (variable names in green)

    Spoiler
    Show
    First, add this constructor to the Card class above printCard:
    Code:
    public Card(String suit, String number) {
      this.suit = suit;
      this.number = number;
    }
    This allows you to create a card with the values suit and number set from the start.

    Then, replace the declaration of the Card object test with these two variable declarations:
    Code:
    String suit;
    String number;
    Giving these the same name as the values of the card mostly serve to reduce the number of changes needed in the code, as the lines that previously would affect the cards values now only change these two variables. You may change them in order to reduce any confusion, but then you'll have to change any reference to suit and number later in the code to the new variable names as well.

    Finally, when you add the card to the ArrayList, replace the current line with this:
    Code:
    deck.add(new Card(suit, number));
    This creates an unique Card object and sets its values at the same time, whereafter it's immediately added to the deck. Since this line of code is repeated 52 times thanks to the outer and inner loops, you'll end up with 52 unique cards in your deck.

    Finally, there's a bug in your printing loop at the end. You take each card out of the deck, name it meow and then call printCard with test, which has the value of the last card inserted, no matter what (although it would generate a compiler error if the above changes were made, since that would remove test entirely). Swap test for meow inside the method call and you should be set.
    Last edited by Teddy; 2012-10-09 at 04:34 AM.
    I'm doing a Tour de Friends! Please drop by and tell me if you're interested in having me drop by for a visit this summer!

    Clouddreamer Teddy by me, high above the world, far beyond its matters...

    Spoiler: Banner by Vrythas
    Show

  19. - Top - End - #49
    Ogre in the Playground
    Join Date
    Oct 2009

    Default Re: ProgrammersitP

    Quote Originally Posted by Teddy View Post
    You're right in your analysis that you create just one card and then modify the value of it. The reason for why it prints out correctly inside the inner loop is because you only print out the last card each time. If you were to print them all out each time, you'd see that they all have the same colour and value in any given iteration of the loop(s).

    The solution is simply to declare 52 different Card objects, which is easiest done inside the loop. I suggest the following changes: (variable names in green)

    Spoiler
    Show
    First, add this constructor to the Card class above printCard:
    Code:
    public Card(String suit, String number) {
      this.suit = suit;
      this.number = number;
    }
    This allows you to create a card with the values suit and number set from the start.

    Then, replace the declaration of the Card object test with these two variable declarations:
    Code:
    String suit;
    String number;
    Giving these the same name as the values of the card mostly serve to reduce the number of changes needed in the code, as the lines that previously would affect the cards values now only change these two variables. You may change them in order to reduce any confusion, but then you'll have to change any reference to suit and number later in the code to the new variable names as well.

    Finally, when you add the card to the ArrayList, replace the current line with this:
    Code:
    deck.add(new Card(suit, number));
    This creates an unique Card object and sets its values at the same time, whereafter it's immediately added to the deck. Since this line of code is repeated 52 times thanks to the outer and inner loops, you'll end up with 52 unique cards in your deck.

    Finally, there's a bug in your printing loop at the end. You take each card out of the deck, name it meow and then call printCard with test, which has the value of the last card inserted, no matter what (although it would generate a compiler error if the above changes were made, since that would remove test entirely). Swap test for meow inside the method call and you should be set.
    Yep thats correct, though the create deck functionality should not be in the card class.
    The card class really should only have the new card(suit,number) and the getter (don´t think you need a setter) and a pint functionality maybe.
    The deck class then should create a deck, shuffle the deck etc.

  20. - Top - End - #50
    Ettin in the Playground
     
    Teddy's Avatar

    Join Date
    Mar 2009
    Location
    Sweden
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Emmerask View Post
    Yep thats correct, though the create deck functionality should not be in the card class.
    The card class really should only have the new card(suit,number) and the getter (don´t think you need a setter) and a pint functionality maybe.
    The deck class then should create a deck, shuffle the deck etc.
    Agreed, but I opted for as few changes to the original code as possible. Also, the printing method could perhaps be exchanged for a toString method, or at least utilise one...
    I'm doing a Tour de Friends! Please drop by and tell me if you're interested in having me drop by for a visit this summer!

    Clouddreamer Teddy by me, high above the world, far beyond its matters...

    Spoiler: Banner by Vrythas
    Show

  21. - Top - End - #51
    Barbarian in the Playground
     
    Ashtar's Avatar

    Join Date
    Jun 2007
    Location
    Switzerland
    Gender
    Male

    Default Re: ProgrammersitP

    Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    I work in a company developing energy optimisation software, I do the main development of the application and part of the calculation kernel (optimization and parallelization). I have a master in computer science.

    What language or languages are you using primarily at the moment? What's your favourite, and why?
    I use C# with .Net 3.5 primarily for the user interface and server programming side of the application. For the calculation kernel, I use FORTRAN with OpenMP as a parallelization library.

    Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    At this point, I really have no idea, I don't know if the future is in programming at all for me or to transition more to a manager / project leader type of role.

    Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    Currently, I'm the main developer of the tool my company sells. That takes all my focus.

    What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    I work with visual studio, both for the C# and for the Fortran (since intel visual fortran integrates with visual studio).

    Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
    My largest problem now is I have a piece of code in fortran for the calculation kernel that parallelizes well on a single motherboard computer (SMP) up to 64 cores, but I now have access to a ccNUMA computer made of 16 blades of 16 cores each (total 256 cores - 2 TB memory) and I have to modify the code to obtain a better speedup. On the ccNUMA system, I'm only getting a max of 16x speedup, when the program is local to one of the blades. I'm really having to dig into the memory and usage of the OpemMP commands. It's driving me mad.
    I need this because the largest problems we run take about 12 hours on a 64 core machine using about 32 GB of ram and I need to bring it down.


    About larger than 3D or more dimensions:
    In our code, when we deal with n-dimensional spaces (we are solving a bellman equation for a multiple state system), we basically covert these n-dimensions into a 1-dimensional array of memory by enumerating (dim1 * dim2 * dim3 * dim4 = maxdim) it to flatten it out.
    Last edited by Ashtar; 2012-10-09 at 09:00 AM.

  22. - Top - End - #52
    Barbarian in the Playground
     
    Miscast_Mage's Avatar

    Join Date
    Dec 2010
    Location
    Ireland
    Gender
    Male

    Default Re: ProgrammersitP

    Edit: *Spoiler'd for length and size*
    Spoiler
    Show

    Quote Originally Posted by Miscast_Mage View Post
    Ah, thank you! I tinkered around with it, and it works perfectly now!



    I had constructors at first as well, but I was looking into getters and setters(something I hadn't specifically looked into yet), and I think I just ended up confusing myself more than anything else. I just took them out for the moment, to make things simpler for a bit.




    This is what was driving me mad; I knew I had to do this, but I simply didn't know how. Many thanks to you, good sir!



    Yeah, I had changed it just to make it easier to post, and I guess I must have missed/messed up with that. It was odd, though; trying to use test (Great idea about using different colour, by the way; I can see it making things a lot clearer.)




    Yeah, I had originally planned to have seperate Card and Deck classes, the Deck handling things like DeckGenerator, or Shuffle; I was just doing everything in the Card class for the moment to test to see if it worked. Probably not the smartest decision in the world though, I admit.



    Personally, I prefer using a print method as all I need from it here is to check to see if it's what it should be, and I like having my own format for that. You wouldn't use a toString method for manipulating something in the object, would you, or is it too just for printing/checking?

    Many thanks, again; you've been a great help.

  23. - Top - End - #53
    Ettin in the Playground
     
    Teddy's Avatar

    Join Date
    Mar 2009
    Location
    Sweden
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    I had constructors at first as well, but I was looking into getters and setters(something I hadn't specifically looked into yet), and I think I just ended up confusing myself more than anything else. I just took them out for the moment, to make things simpler for a bit.
    Why not do both? Although setters are only relevant if the value in the object should be possible to modify after declaration (which isn't really the case for cards).

    Quote Originally Posted by Miscast_Mage View Post
    This is what was driving me mad; I knew I had to do this, but I simply didn't know how. Many thanks to you, good sir!
    I'm always happy to help.

    Quote Originally Posted by Miscast_Mage View Post
    (Great idea about using different colour, by the way; I can see it making things a lot clearer.)
    Yeah, when writing the post, I realised that things were pretty quickly going to become confusing if I kept writing variable names like any other word, so I borrowed the idea of colouring variables from the way many IDEs tend to do it.

    Quote Originally Posted by Miscast_Mage View Post
    Yeah, I had originally planned to have seperate Card and Deck classes, the Deck handling things like DeckGenerator, or Shuffle; I was just doing everything in the Card class for the moment to test to see if it worked. Probably not the smartest decision in the world though, I admit.
    In a program this small, it doesn't matter especially much, but when you're working with larger projects, it generally saves you a lot of time to do them as separate parts to start with.

    Quote Originally Posted by Miscast_Mage View Post
    Personally, I prefer using a print method as all I need from it here is to check to see if it's what it should be, and I like having my own format for that. You wouldn't use a toString method for manipulating something in the object, would you, or is it too just for printing/checking?
    The method toString() prints information about an object as a string. It already exists in the Object class (which all classes automatically extend). If you tried...
    Spoiler
    Show
    Code:
    Card noir = newCard("Spades", "J");
    String s = noir.toString();
    System.out.println(s);

    ...you'd get some cryptic numbers which I think are an ID-number of some sort. By defining your own toString() method, you can decide what to print, for example...
    Spoiler
    Show
    Code:
    public String toString() {
      return(number + " of " + suit);
    }

    ...would make the output of the previous code block "J of Spades".

    What also is worth pointing out is that toString() is automatically called on an object when you call println() with it, so...
    Spoiler
    Show
    Code:
    Card noir = newCard("Spades", "J");
    System.out.println(noir);

    ...is equivalent in output to the first code block.
    I'm doing a Tour de Friends! Please drop by and tell me if you're interested in having me drop by for a visit this summer!

    Clouddreamer Teddy by me, high above the world, far beyond its matters...

    Spoiler: Banner by Vrythas
    Show

  24. - Top - End - #54
    Ogre in the Playground
     
    Neftren's Avatar

    Join Date
    Nov 2006

    Default Re: ProgrammersitP

    I'm no expert in Java, but my hunch would be that calling toString() on an object without an overloaded toString() method would print the memory address or something similar to that degree.




    Also, that silly moment when you realize sys.maxint returns a 64-bit number locally, but a 32-bit number on the deployment server.

    Yeah. That just happened to me.

  25. - Top - End - #55
    Ettin in the Playground
     
    Teddy's Avatar

    Join Date
    Mar 2009
    Location
    Sweden
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Neftren View Post
    I'm no expert in Java, but my hunch would be that calling toString() on an object without an overloaded toString() method would print the memory address or something similar to that degree.
    Possibly, but since Java goes through great lengths to conceil the actual working mechanisms of the memory management, and since the numbers are seemingly arbitrary, I'm open for other possibilities as well...

    Quote Originally Posted by Neftren View Post
    Also, that silly moment when you realize sys.maxint returns a 64-bit number locally, but a 32-bit number on the deployment server.

    Yeah. That just happened to me.
    Let me guess, you're running a 64-bit machine.
    I'm doing a Tour de Friends! Please drop by and tell me if you're interested in having me drop by for a visit this summer!

    Clouddreamer Teddy by me, high above the world, far beyond its matters...

    Spoiler: Banner by Vrythas
    Show

  26. - Top - End - #56
    Ogre in the Playground
     
    Neftren's Avatar

    Join Date
    Nov 2006

    Default Re: ProgrammersitP

    Quote Originally Posted by Teddy View Post
    Let me guess, you're running a 64-bit machine.
    Yeah, this is for Google App Engine using the Python SDK. I'm running this locally in OSX 10.8.2 (x86_64) whereas Google's server is running some flavor of 32-bit ... I want to say Linux.

    Anyways, I got my datastore query working now. Yay!

  27. - Top - End - #57
    Barbarian in the Playground
    Join Date
    Jul 2007
    Gender
    Male

    Default Re: ProgrammersitP

    Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    I taught myself (slowly and inconsistently) from the internet. I do it in my spare time.

    What language or languages are you using primarily at the moment? What's your favourite, and why?
    I only know java. It doesn`t look like I`ll have to deal with other OS other then windows anytime soon, but I like the idea of it working the same on any OS.

    I read a bit about other leanguages, but I won`t be able to do much with any of them (maybe a bit with SQL).


    Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    My abstract goal is to know how to program anything I`ll want to, and be able to do it (not including things like artifical inteligence). I might work in programming in the future.

    Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    I have too many project ideas. I decided that my main focus would be on utility classes and methods, and other then that I work on things at random. Right now I`m a bit focused on mathamatical stuff - I wrote a class that represents a simple fracture (3/4, 1+2/5, etc), which works well. It used 3 int values, and I decided they should be longer. So I`m working on an arbitary length integer class to replace the int values with (yes, I know one exists with java - one of my projects is making my own versions to some of the classes in java).

    What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    The unsynchronized console in NetBeans irked me (that and a few other features), so I passed to Eclipse, and I might get sick of it too eventully.

    Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
    I hate it when I make obvious mistakes. Those are the easiest type to detect and fix, but it`s still annoying that I accidently used about half of java reserved keywords while writing a class.

    Quote Originally Posted by Miscast_Mage View Post
    *card stuff*
    A note about the card class:
    I think it would be better if you used Enums instead of String values for Suit and Number. That way if you accidently insert incorrect values to the constructor, the program would fail instantly with obvious reasons instead of messing up things later.

    The way the toString method is implemented by default is by returning the class name and it`s address in hexdecimal format.
    A world behind the mirror (stand alone plane)

    (Wall) passer, a rogue variant

    My not realy extanded homebrewer signature

    Quote Originally Posted by Grinner View Post
    In a world ruled by small birds, mankind cannot help but wonder how this state of affairs came about.

  28. - Top - End - #58
    Barbarian in the Playground
     
    Flumph

    Join Date
    Dec 2011
    Gender
    Male

    Default Re: ProgrammersitP

    Hi!

    I just started looking at Executable UML, does anyone have any experience with it, or any tips regarding learning it?
    Away on vacation 19-23 March, posting will be minimal.

    Dumbledore is dead but had a horcrux so might still be alive to it being fake and him dead but not stopping her from using the having a horcrux on you letting you live from a killing curse.
    Quote Originally Posted by The Glyphstone View Post
    Epileptic monkeys. Boxing gloves. Typewriters. That is all.

  29. - Top - End - #59
    Bugbear in the Playground
     
    Krazzman's Avatar

    Join Date
    Jul 2011
    Location
    Aachen, Germany
    Gender
    Male

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    [*]Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    Working, but not really as Programmer. Was employed after my apprenticeship as "Fachinformatiker im Fachbereich Anwendungsentwicklung".
    Passed that with a 4+ (D+ in American grading system) due to the Commission (IHK) not getting what my Project was about and having a blackout at the exam...
    [*]What language or languages are you using primarily at the moment? What's your favourite, and why?
    ATM I work with COBOL but I would like to do more with Java which I might come to in the future... but then more in terms of hobby not for cash as it seems.
    [*]Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    Staying at my job as it is not really programming more maintenance of the systems for Insurance Companies but it is quite fun. And pretty damn well payed
    [*]Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    Nothing really at the moment. Messed some Tables up today but got to fix that again...
    [*]What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    For COBOL we use the RDz (Rational Developer for System z) a sort of Homemade version of an Eclipse environment similar to the RSA (Rational Software Architect from IBM). It is quite well made and once configured works really well. At home I used IntelliJ for school stuff
    [*]Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?[/LIST]
    COBOL Global Variables... seriously... confusing stuff when encountered the first time
    Have a nice Day,
    Krazzman

    Currently Playing:
    Drako:[3.5] Human Warblade 3/Fighter 2(Hiatus)
    Desmond:[3.5] Human Cleric of Tymora 3/Warlock 1(Hiatus)
    Nikolas:[PF] Human Sage Sorcerer 11(Hiatus)
    Tokias:[PF] Tiefling Heretic Lamashtu Inquisitor 3
    "Ed"uardo:[3.5] Azurin Totemist 4(Hiatus)
    Garm Frost:[SWSE] Human Scout1/Jedi1

  30. - Top - End - #60
    Ogre in the Playground
     
    Kallisti's Avatar

    Join Date
    Jun 2009
    Location
    The Riddlerealms

    Default Re: ProgrammersitP

    Quote Originally Posted by Miscast_Mage View Post
    • Where are you and what are you doing in terms of programming? Employment, education or in your spare time?
    • What language or languages are you using primarily at the moment? What's your favourite, and why?
    • Where do you hope to go with your programming? Any plans for the future, or just waiting to see if anything of interest comes along?
    • Any projects, personal or otherwise, you're in the middle of? Anything you're really focused on?
    • What environment do you work/prefer to work in? Netbeans/Eclipse/Command line and a text editor?
    • Any problems that are driving you mad? A piece of code not compiling right, or being off by one, or one little syntax error in a sea of code? Not quite grasping the logic of a particular piece of code?
    I've been studying Python using the free courses on the internet--particularly Udacity--in my spare time. I've played with Python, Ruby, JavaScript and C++, but Python's the only language I both found a robust set of tutorials for and made time to stick with. Mostly I've been enjoying it, although I started with Ruby and will occasionally be annoyed by something Ruby had and Python lacks.

    I have a few projects I'd like to complete eventually, mostly for personal use, but my main motive to study programming is that it seems interesting. I really enjoy the problem-solving, although it irritates me that my toolset (read: my knowledge of the language) is incomplete; it feels akin to wrestling for a logic puzzle for hours on end before the guy who posed it goes "Oh! I just remembered, there's a clue I was supposed to give you, you won't be able to solve without it..."

    My most immediate project is a program that will take parameters for a given RPG's die system and output some statistical calculations--so you could ask how likely you are to succeed in a given opposed roll in nWoD or how many hobgoblins your ranger can kill before getting nat-20'd to death. Eventually I'd like to release it as a series of free apps--one for each system I end up supporting.

    I generally use the built-in interpreter in Udacity simply because it's what I'm provided, but if a piece of code is giving me serious trouble I'll move it into PyScripter to take advantage of some of its IDE features; I have Eclipse on the Linux the friend-who-is-actually-good-at-computers insisted I should be able to dual-boot, but I almost never use it--I found the sizable feature set a bit overwhelming and I like PyScripter better visually, which matters if I'm going to be staring at a screen for hours on end. I know I can customize the appearance of my Eclipse install, but that's a lot more work than I want to do to turn Eclipse into PyScripter when I already have PyScripter.

    Currently there aren't any problems driving me too crazy, although several of the challenges of Udacity give extra kudos for more parsimonious code and I'm utterly stumped as to how some of those could be solved in just a few lines of code.
    Last edited by Kallisti; 2012-10-12 at 11:29 PM.
    Hail Eris/All Hail Discordia/Fnord?
    Quote Originally Posted by Lix Lorn
    ...Kallisti, your table and poem skills are possum!
    Quote Originally Posted by Milskidasith
    I'm not sure whether you are brilliant or insane. I think it's both.
    "Once upon a time, a story was never finished..."

Posting Permissions

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