## NathanMullenax's Profile User Rating:

Reputation: 103 Stalwart
Group:
Contributors
Active Posts:
220 (0.17 per day)
Joined:
23-September 12
Profile Views:
10,515
Last Active:
Mar 20 2016 05:48 PM
Currently:
Offline

### Previous Fields

Country:
Who Cares
OS Preference:
Linux
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Classic
Who Cares
Dream Kudos:
75

### Latest Visitors

NathanMullenax Former programmer, current 'kitchen dude'.

1. #### In Topic: Converting Math Formula to Java help

Posted 20 Jan 2015

Attack and defense are both integers, so you are doing integer instead of floating point divisions. So, 3/7 = 0. You could store them in doubles to begin with. You can even keep the 'nextInt' part and store it directly in a double.
2. #### In Topic: Simplifying queries

Posted 19 Jan 2015

First I would factor out the sub_page != 'sub_sub_page' and userid='2' part, since it occurs in both 'and' conjuntions.
```SELECT COUNT(id) FROM pages WHERE (sub_page != sub_sub_page AND userid='2') AND (title LIKE '%library%' OR text LIKE '%library%')
```

Use parens wherever it makes it easier to read. It's helpful to remember that 'and' is like multiplication and or is like addition as far as which is evaluated first in expression. That is, when you evaluate A and B or C and D, it's interpreted like this: (A and B ) or (C and D). When in doubt, use parentheses to make it easier to interpret.

Your search options could be encoded as conjunctions. Let's say you pass a string parameter '%1', which takes values 'title', 'text', and 'both'.
```... WHERE sub_page != 'sub_sub_page'
AND userid = '2'
AND
(
( ('%1' = 'title' OR '%1' = 'both') AND title LIKE '%library%' )
OR  ( ('%1' = 'text' OR '%1' = 'both')  AND text LIKE '%library%' )
)
```
3. #### In Topic: Why do I get the error - "being used without being initialized"

Posted 19 Jan 2015

Because you haven't initialized 'q'. When you create a pointer you've only allocated a place to hold the address of an object. You also have to allocate the space for it. You can do this using 'new'.
```bintree_node *q = new bintree_node();
```

New allocates memory, runs the constructor, and then passes you a pointer to the newly created object. When you allocate something this way, you also need to free the memory when you're done with it. This is done using delete example:
```#include <iostream>
int main()
{
int *p = new int(); // allocate space for an int
*p = 4;
++(*p);
std::cout << *p << "\n";
delete p;           // free space allocated for int
}
```
4. #### In Topic: (java) Help With Simple Assignment

Posted 18 Jan 2015

Yeah, why not? From your assignment it looks like you also need to do error checking (see Scanner.hasNextInt()).
5. #### In Topic: Which algorithm is used?

Posted 18 Jan 2015

It doesn't necessarily have a name. It's a simple heuristic.

If you're curious what 'minimax with alpha-beta pruning' looks like, that's over here in SML:

Minimax search and Alpha-Beta Pruning

### My Information

Member Title:
Age:
32 years old
Birthday:
December 29, 1983
Gender:
Location:
Fort Myers, Florida
Full Name:
Nathan Mullenax
Programming Languages:
C++, Java, SML/NJ, QBasic, Haskell, C#, ColdFusion, SQL, PHP, Python, INTERCAL

E-mail: