Martyr2's Profile User Rating: *****

Reputation: 4913 Guru
Group:
Mentors
Active Posts:
13,370 (4.05 per day)
Joined:
18-April 07
Profile Views:
257,188
Last Active:
User is offline Apr 26 2016 10:31 PM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

Latest Visitors

Icon   Martyr2 is most definitely the real life Tony Stark.

Posts I've Made

  1. In Topic: Favourite drink while coding

    Posted 26 Apr 2016

    Ahhh the memories. I use to be a Dr. Pepper fan myself. I haven't had a drink of soda in nearly 8 years. I have been completely off caffeine for nearly 5 years. I drink water and green tea. However I have been doing Synergy grape kombucha tea drinks which mixes grape juice with kombucha tea. Low in sugar but feels very "popish"

    :)
  2. In Topic: Linked List Node Order Print Error

    Posted 26 Apr 2016

    Ok well you have a problem in your add there around lines 71 to 88. You see you set head if it is null to a new node. But that should be the end of it. However you continue after that and go through the process of creating the node again on line 76 and then in through the loop to add it to your list. This means you are going to add the node twice. Once for the head and then starting with the head add it again.

    This process should be an if else statement. If head is null, create the new node and set it to head. ELSE start from the head and loop through until you hit null and add it.

    Then in your toString you check if head is null and if not, you set the current object to the next node after head. See a problem here? You are actually skipping head. Set jacobCurrent to head, it won't be null in your first pass of the while loop and you can go about outputting it. Then go to the next element.

    Both of these issues probably won't address the null pointer exception, but that error could just be a symptom of the other problems. Take a look at those two places again and make the adjustments and rerun it. If the error continues, then re-report the error message. The error is giving you a line number so check that line number as well.

    :)
  3. In Topic: Problems with abstract classes.

    Posted 25 Apr 2016

    Which variables are coming out zero? Have you put a breakpoint in side ArmorItem's generateArmorLore() function to see if "armor" is zero? As in, could it be your loreChance function returning zeros or if armor_percent is zero at that point. I think a breakpoint and a bit of variable watching can help you get to the bottom of this real quick.

    :)
  4. In Topic: Making a Variable Readable For Multiple PHP Scripts

    Posted 25 Apr 2016

    You can use sessions to help with this. Look up PHP Session variables which are variables that you can carry for the lifetime of a particular session on your site.

    Session variables are really easy to use.

    Now one thing I also want to mention is that you should never use values passed to you through a form to dynamically create an SQL string. In your insert.php script you use various variables to insert values into your database. You put those variables directly into the insert statement and execute it. This opens you up to SQL injection attacks and is a really big problem.

    You can get around this by using PHP's PDO or MySQLi objects/procedural functions and bind your variables into the statement. If you are familiar with mysql_query then you might find MySQLi a simple replacement. Use its bind method to bind your variables. The PHP website shows some examples of how this is done... http://php.net/manua...-statements.php

    Good luck and hope this helps you out. :)
  5. In Topic: Connect 4 help (Make the pieces drop to the last row)

    Posted 25 Apr 2016

    Ok here is a tip, when you start seeing things like lines 20 - 61 appearing and like lines 140 - 182 or like lines 307 to 450 where there is a lot of repetition you should immediately start thinking about simplification. Since these lines only differ by a few changing items, you should start thinking loop.

    for (int i = 1; i <= 6; i++) {
       for (int j = 0; j <= 5; j++) {
           if (clicked == board[i][j]) {
              // Do something
           }
       }
    }
    
    


    This code above could remote everything from 307 to 450 essentially. You want to strive for simplicity here which will make things much much easier for you going forward and solving other issues.

    Now I am going based on your topic that you are trying to find the furthest point a chip can drop in a column. I suggest you write a small function that takes a column number and returns a position on the board representing the location in that column for the chip. So lets say that you have one chip already in column 1, you would feed the column 1 to the function and using that column it would iterate through each item row by row until the row is 5 (no chips in column), the column is full or until you finally encounter a row where a chip is located.

    function int FindLocation(int column) {
       // First check if the column is full...
       if (board[0][column] != null) {
         return -1; //<--- some way to say this column is full
       }
    
       for (int i = 1; i <= 5; i++) {
           if (board[i][column] != null) { //<-- If we found a chip
              return i - 1; //<--- return the row right before it as being empty
           }
       }
    
       return 5; //<-- No chips found, so put in furthest row down in column 
    }
    
    


    This is off the top of my head but hopefully it gives you the idea of how you can find the first empty spot in a column. It returns the row number so once you have that you know that board[row][column] is going to be where you put the chip you are placing into the board.

    Hope you get the idea. :)

My Information

Member Title:
Programming Theoretician
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Vancouver, Canada
Interests:
I love programming and science (almost became a chemist). My favorite languages are C#, Java, Python and PHP. While I am not programming I enjoy movies that feature something medieval (Gladiator, Braveheart etc) or high tech (like Hackers or Swordfish).

I have a diploma in computer science and another in arts and science. My favorite sciences are astronomy, chemistry and geology.

If you have any questions regarding programming, you will find I live and breathe the stuff and should prove an invaluable asset.

Winner of 31 (yes 31!) 2008-2015 DIC Community Awards including Blog of the Year, Mentor of the Year, DIC Head of the Year, Most helpful Programming Category, Most Helpful in Web Development Category and overall Nicest Member of the year.

You can now catch me on Twitter! Follow me as I talk about technology and specifically programming and answer questions like the best book to learn from or how to organize your code.

http://twitter.com/martyrscry :)
Years Programming:
17
Programming Languages:
C/C++/VC++/C#, VB6/VB.NET, Java, JavaScript, Ruby, HTML/CSS, PHP, ASP/.NET, Python, mIRC Scripting

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.coderslexicon.com
Facebook:
http://www.facebook.com/coderslexicon
Twitter:
martyrscry

Comments

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

    rooster24 Icon

    21 Oct 2015 - 09:03
    I bought your Programmers Idea Ebook. Do you have Java solutions to some of the Projects that I can reference as needed?
  2. Photo

    Dogstopper Icon

    05 Dec 2013 - 14:39
    Have a 6-year badge good sir!
  3. Photo

    mostyfriedman Icon

    12 Oct 2013 - 21:07
    I am good, busy as well.
  4. Photo

    Martyr2 Icon

    07 Oct 2013 - 12:16
    Good mosty, you? Been busy lately.
  5. Photo

    mostyfriedman Icon

    07 Oct 2013 - 11:26
    Martyr2 my man, how's it going??
  6. Photo

    ishkabible Icon

    22 Aug 2013 - 15:58
    O ah, didn't even realize it. No prob. much deserved!
  7. Photo

    balloon1 Icon

    18 May 2013 - 14:57
    Hi can you help me with one of my questions!
  8. Photo

    groovmuffn Icon

    24 Apr 2013 - 10:10
    Greetings! Newish coder here. I came across your php histogram equalization code the other day and figured I'd try and draft something similar up in javascript. I feel like my code is sound, though something has to be wrong as the output of the image is black with some faint greens. I'm wondering if I am missing something from your original code. Consider perusing a jsFiddle?
  9. Photo

    Martyr2 Icon

    31 Dec 2012 - 12:48
    Thanks lucky3! Winning these types of things always energizes me to continue my work to help everyone I can here. I am a firm believer that we should always provide more than just a quick answer, but teach as well. :)
  10. Photo

    lucky3 Icon

    31 Dec 2012 - 02:23
    Congratulations for the "Mentor of the Year" 1st place, "Nicest Member of the Year" 1st place, "Most Helpful- Web Development" 1st place, and "DIC Blog of the Year" award 3rd place awards! Really impressive, and well deserved.
  11. Photo

    xwordgrl Icon

    27 Dec 2012 - 14:26
    Martyr2, I’m a reporter for the Wall Street Journal and would like to ask you a question about your post on Code Academy. Please email me at [email protected] Thanks!
  12. Photo

    MsParnel Icon

    16 Sep 2012 - 23:17
    Thank you very much for the project list :).
  13. Photo

    ishkabible Icon

    19 Feb 2012 - 20:19
    "This is Chris's basement!!!"
  14. Photo

    Martyr2 Icon

    19 Feb 2012 - 12:47
    Very very true. echo "THIS IS SPARTA!!!";
  15. Photo

    no2pencil Icon

    19 Feb 2012 - 11:51
    It's like the movie 300. 10 times.
  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »