Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Captacha

Member Since 27 Nov 2011
Offline Last Active Apr 05 2013 10:33 AM
-----

Topics I've Started

Textbook question about OOD with odd answer

05 April 2013 - 09:34 AM

I'm currently taking a AP programming course, and since I know most of the material already, I sometimes assist my teacher. The class is studying Object Oriented Progamming and Design in Java. My teacher and I were reviewing questions from the textbook which the class was working on, when we spotted answer that looked suspicious. I don't have the question with me right now, but it was something like this:

 

"What relationship tends to indicate a dependency?

a) IS_A

b) HAS_A

c) KNOWS_ABOUT

answer: c"

 

I was a bit confused about this answer beacuse I have never heard of a KNOWS_ABOUT relationship before this. I am aware of the IS_A and HAS_A relationships from the programming book I read when I first started programming. Have you ever heard about the KNOWS_ABOUT relationship, and are we wrong?


std::vector issues

12 February 2013 - 11:57 AM

In the last week or so, I've been attempting to implement pathfinding for my first time. I've been reading a tutorial on the general concept and have been trying to implement it on my own. For the Closed List and Open List, I use std::vector. The guide says once I find the optimal node to delete it from the Open List and add it to the Closed List. I'm doing that with this code:

 

closedList.push_back(openList[lowF]);
openList.erase(openList.begin()+
lowF);

 

The issue is that the wrong node is being deleted from the Open List, causing the pathfinding calculations to flow in an infinite loop. For Instance:

 

Closed List = (9,4)

Open List = (9,3) (10,4)

 

After the code I posted above executes, the vectors look like this:

 

Closed List = (9,4) (9,3)

Open List = (9,3)

 

While they should look like this

 

Closed List = (9,4) (9,3)

Open List = (10,4)

 

I checked the lowF value, and it is 0. So openList.erase(openList.begin()+lowF) should be the same as openList.erase(openList.begin()). For some reason, that line of code is deleting the second element in the vector instead of the first. I'm attaching a error log file I printed out. I'd appreciate any help. ty


Bit Flags vs. Boolean

10 October 2012 - 07:45 PM

I was trying to explain to a semi-programmer friend of mine today the purpose of Bit Flags vs. Booleans. And I couldn't think of any besides Memory Usage which seems rather weak seeing as it would save you a few 100 bytes of memory at most. So what's a could argument for Bit Flags I can tell him about, and to be honest I'm wondering myself right now too.

C++ -- Undinitialized Variables

06 October 2012 - 06:10 PM

I was just writing a small program today converting csv files to xml, and I noticed something weird was happening. I had an array of doubles that was being iniatialized near the end of the program using an array of strings, atof(), and a for loop. When I commented out the initialization and left only the declaration, I got some runtime errors. Then when I commented out the declaration, the program ran fine again. I've never had this happen to me before, so I made a short test program. All it was was an integer declaration, and it ran fine. Any idea what's causing this?

Testing for Whole Numbers

13 August 2012 - 11:04 PM

How can I test if a certain expression evaluates to a specific data type? For Instance:
int i = rand%10+1;
if(i/3 == int)
   do this

PARTNERS