jon.kiparsky's Profile User Rating: ****-

Reputation: 7294 Overlord
Group:
Mentors
Active Posts:
12,173 (10.79 per day)
Joined:
19-March 11
Profile Views:
96,851
Last Active:
User is online 31 minutes ago
Currently:
Viewing Topic: nullpointer exception

Previous Fields

Country:
US
OS Preference:
Mac
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
Java

Latest Visitors

Icon   jon.kiparsky Life is short but the night is long

Posts I've Made

  1. In Topic: What does it mean when it requires a string and int?

    Posted 20 Apr 2014

    Your method is defined as taking two parameters, a String and an int. You've given just the int, so the compiler doesn't know what to do about the String part.

    (In the future, please post source code and errors as text. Text is the format to use for the web: it requires less bandwidth, it's easier for your browser to work with, it's searchable, and it can be accessed by the visually impaired.
  2. In Topic: Introduce Yourself

    Posted 20 Apr 2014

    View PostAkasen, on 19 April 2014 - 11:25 PM, said:

    I wish to learn though and I wish to dedicate myself more to projects rather than floundering about reading up theory and watching online lectures and classes. I have been told there is only so much schooling can do to benefit you. I need to apply myself to this if I want to truly get better at it.



    Just got an announcement of that Tim Roughgarden's algorithms 1 course is running again starting at the end of the month. This is a very good overview of algorithms and how to think about them, and the programming assignments will certainly make you apply yourself. Might be useful for you. At least, I found it very useful when I took it.
  3. In Topic: Hitting a wall with text Adventure game - Need suggestions

    Posted 20 Apr 2014

    I feel like this might do well with a better design and a more object-oriented structure. I would start by trying to make it a bit more modular. For example, if you can separate the parsing of incoming commands from the execution, then it'll be a lot easier to handle both.

    So you might want to define a very small language with a very simple structure, and write a little parser for it. I would suggest something that accepts transitive and intransitive verbs, in imperative form only, and avoid homonyms. If you do that, then you can easily parse commands from the left, and construct a little command object, which you can pass in to the game engine.
    You would also be able to capture input errors at the parsing stage, and handle them without involving the game engine, which is a nice simplification.

    In the game engine, you'd try to apply the command: if the command is applicable in the current game state, then you'd execute it, otherwise you'd return an error.
    Notice that now you have two layers of error: parse errors if the sentence just doesn't make sense or uses words the game doesn't know ("Sleep north", when 'sleep' is an intransitive, or "Walk aft" if the game doesn't know about nautical directions) and application errors, if the sentence can be parsed but doesn't apply to the current situation. ("Kill troll" when there isn't a troll nearby) This is actually nice, because these are very different situations and you'd like to handle them separately.

    How you implement this idea of a "command object" is an interesting question. The classic command object is an object with an "execute" method which can get called when needed. This is how it's described in the GoF book, for example. But in a language like python with first-class functions, you might simply want to compose a function and send that along. If you want to handle "undo" functionality, it's probably best to use the full-on command object, because this will allow you to compose an undo function, which you can put on an undo stack. Then if the player regrets trying to light the birthday candle with the blowtorch, they can say "undo" and you pop the stack, execute the undo function that you get, and foop, you're in the previous state. You can of course do this with the first-class function approach as well but that sounds like it might get a little complicated.

    For handling player movement, the most obvious approach is for each area to have a dict of exits, where each exit is a mapping of direction to area. You might want to keep track of area objects in a larger structure, and end up with something like:

    livingRoom.exits = {'east': map['outside_the_house'], 'down': map ['basement'], 'north': map['kitchen']}
    


    But this is just me making stuff up now. I would suggest that you try to separate out the parsing first, which will simplify your logic a fair bit, and then you can start thinking about how to represent and manipulate game state.
  4. In Topic: Java Programming assistance with array list

    Posted 20 Apr 2014

    The DIC filter is me and Dmitri and anyone else who's going to show you how each error is fixed. I appreciate that this is difficult for a beginner - but these are really easy problems, in terms of programming. You're going to have to get used to fixing stuff like this, finding errors like this is really how you learn the language. Just applying changes that I tell you about isn't going to help you much. Reading your code and reasoning about it and testing hypotheses is how you're going to get to where you need to be. Yeah, it's a little painful, but it's a hurdle you're going to have to get over. Might as well go for it now.

    So my best advice is to take them one at a time and try to work out what the compiler is trying to tell you.

    "cannot find symbol" means that you've referred to something that the compiler doesn't know about. Usually, it means either a typo or you've messed up an import. In this case, it's not an import. Knowing that, and having a line number, you should be able to make a a good guess about what the problem is, and how to fix it. Give it a try. If your fix doesn't work, think about it some more, come up with another hypothesis, and test that. Eventually it will work. This is what programming is about - welcome to it.
  5. In Topic: Java Programming assistance with array list

    Posted 20 Apr 2014

    Okay, at this point I feel like you're not really participating in this process - you're just passing the code through the DIC filter to remove the bugs.
    I think you should probably try to track down these errors on your own. They're all pretty straightforward. Remember that Java is case-sensitive. Think about the logic. If you can't see the issue, take a few minutes and step away from the problem, then take another look.

My Information

Member Title:
Pancakes!
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Boston, MA
Interests:
Translation (Portuguese, German, Spanish), accordion (Hohner Black Dot B/C), flute (Casey Burns, Skip Healy 3-piece), homebrew (beers and meads)
Full Name:
Jon Kiparsky
Programming Languages:
Java, python, scala, perl, c, various lispen, bits and pieces of this and that

Contact Information

E-mail:
Private

Comments

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  1. Photo

    helpheimer Icon

    18 Apr 2014 - 00:12
    prevented my noob brain from melting multiple times :)
  2. Photo

    Preacher2012 Icon

    30 Mar 2014 - 16:32
    you give great help, mind help me with my cipher lab?
  3. Photo

    yashwanth.c.b Icon

    02 Mar 2014 - 00:20
    wow....jon thank you...i am happy thar i've got reps from you.... :)
  4. Photo

    BenignDesign Icon

    23 Dec 2013 - 22:32
    Rawr. I love it when you talk nerdy.
  5. Photo

    BenignDesign Icon

    23 Dec 2013 - 08:54
    And what's wrong with library cred? A well read man is a sexy man.
  6. Photo

    BenignDesign Icon

    18 Dec 2013 - 13:35
    Gotta maintain that computer geek street cred.
  7. Photo

    BenignDesign Icon

    18 Dec 2013 - 13:11
    Your theme song is both hysterical and sad. I doubt the truth in it, but I get the point.
  8. Photo

    modi123_1 Icon

    26 Nov 2013 - 07:35
    http://motherfuckingwebsite.com/ -> a new project of yours?
  9. Photo

    modi123_1 Icon

    13 Nov 2013 - 12:03
    Heh - waves are fun. http://imgur.com/gallery/5SupAbL
  10. Photo

    BenignDesign Icon

    27 Aug 2013 - 12:01
    Naked ladies always dig the accordion player.
  11. Photo

    BenignDesign Icon

    27 Aug 2013 - 11:30
    The fact that you do weird shit like learning to play the accordion on a whim is why I freaking love you. <3
  12. Photo

    BenignDesign Icon

    24 Jun 2013 - 12:29
    My immediate assumption was you... however, without being 100% certain as I was unable to find it again in my skimming, I did not want to give incorrect attribution to such a fine piecing together of the English language.
  13. Photo

    BenignDesign Icon

    05 Jun 2013 - 10:19
    Haha! Anytime! I'm curious to see those bad ass running shorts.
  14. Photo

    BenignDesign Icon

    03 Jun 2013 - 13:14
    You've only been here two years? Damn! This has been the longest two years EVER.
  15. Photo

    Precise Icon

    18 May 2013 - 12:30
    Hello, I need to speak with you personally about something. Can I get an email please?
  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »