Antenka 274 Posting Whiz

Hello, ddanbe.
I was playing with your code ... I'm not sure, that this is what are you looking for:

this.AutoScroll = true;
if (ColumnCount > cMaxCol)
    {      
      CC = cMaxCol;
      RC = this.RowCount;
      ColScr = 0;
    }
    else if (RowCount > cMaxRow)
    {
      CC = this.ColumnCount;
      RC = cMaxRow;
      RowScr = 0;

    }
    else
    {
      this.AutoScroll = false;
      CC = this.ColumnCount;
      RC = this.RowCount;
    }
Antenka 274 Posting Whiz

Just to add: you can use the alternative way (a bit longer, but still can be useful some day :) ). For the case, if you don't want to interrupt your prog when the user inputs the incorrect value. You can design a method, using Class Character. This class contains method isDigit(), that can help you check, whether the given character is Digit.
Then you can do whatever you want (in case if user input incorrect value):
1. Replace the value, entered by user by default value.
2. Remove all incorrect symbols from it and return the proper value.

Antenka 274 Posting Whiz

Hello, Allen.
You close your BufferedWriter bw in the cycle (when you are writing data into the file). So in the best case you'll have an empty file ... in worst - an exception.
Just take it out of the cycle.

stephen84s commented: Ahh !!! Neither did I notice the close() inside the loop +5
Antenka 274 Posting Whiz

It happened because you calling maxF and maxC methods before you are filling arrays inputFahr and inputCel with data. And your maximum goes through arrays, filled by default values (in your case it's zeros).

And one more thing: (correct me if I'm wrong) you want the user to input each number directly. If so, you should correct your methods, what filling arrays. You have only this to read data entered by user to fill arrays:

double fahrenheit = input.nextDouble();

and

double celsius = input.nextDouble();

that means, that you're reading only the first value, entered by user and filling by it whole array. If it must be different values (within the limits of each array), you should place that into cycle.

Ezzaral commented: Helpful advice. +16
Antenka 274 Posting Whiz

Hello, gallian99.
I haven't heard about such standard functions :) I can offer two alternative ways for you:
1. Using reference types (like ArrayList). You'll able to add elements dynamically and get the actual size of your array.
2. Create your own structure/class, that will contain your array, the full array size (in your case it's 50) and number of added elements.

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

how about looking in MSDN for ComboBox Class?

Antenka 274 Posting Whiz

if so, mark this thread as solved, please :)

Antenka 274 Posting Whiz

lolz ... :) Good luck!

Antenka 274 Posting Whiz

You have mistake in word Entries in the 'RemoveEmptyEntires'.

ddanbe commented: Well noticed! +4
Antenka 274 Posting Whiz

in your case it doesn't matter, which way you use to add 1. I suppose that you was talking about "+=" operator?
Let's see:
1.

Empleados.numeroemp++;

increasing numeroemp by 1.
2.

Empleados.numeroemp += 1;

which is the short version of this:

Empleados.numeroemp = Empleados.numeroemp + 1;

3.

Empleados.numeroemp  = + 1;

here you assign numeroemp by +1.

Antenka 274 Posting Whiz

Oh yeah :( sorry. First part is your's. Wasn't about to do things like that O.O ... it seems that I need rest a bit ;P

Antenka 274 Posting Whiz

It also works proper with me, but have some thing, that you should look at:
1. You check Parent_Name 2 times. And second one is inside the first one. It looks like question: "Are you really sure that (Parent_Name != null)" ;P

treeView1.Nodes.Clear();
            if (Parent_Name != null)
            {

and

if (Parent_Name != null)
                    {
                        foreach (string filename2 in Child_Name)

2. I suppose you should do that:

treeView1.Nodes.Add(ParentNode);

after you fill with data the ChildNode of this ParentNode.


Good luck :)

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

Antenka, you were right , readToEnd() is string format , but its not an array

Didn't said, that this is array. That part of code was taken from your's first post ...

Antenka 274 Posting Whiz

Maybe your troubles caused by way, you use to read from stream?

foreach (char S in reader.ReadToEnd())
Antenka 274 Posting Whiz

x = 1
N1 = x to x + 15
x = x + 15
N2 = x to x +15
...

The 16th file will be displayed on N1 and on N2. I suppose you need this correction:

x = 0
N1 = x + 1 to x + 15
x = x + 15
N2 = x + 1 to x +15
...
Antenka 274 Posting Whiz

Hello, cVz.
StreamReader.ReadToEnd method has this signature (taken from MSDN):

public override string ReadToEnd()

The returning type is string.
Am I misunderstood something?

Antenka 274 Posting Whiz

here is something, that will throw light on that problem: SqlConnection.ConnectionString Property

and in that string:

conn.ConnectionString = new conn();

you're trying to assign ConnectionString property by creating new instance of the instance of the class SqlConnection.

Antenka 274 Posting Whiz

oops ... sorry wrong line. What are you trying to do here:

conn.ConnectionString = new conn();
Antenka 274 Posting Whiz

What are you trying to do here:

SqlConnection conn = new SqlConnection();

Here is an example for you: SQL connection example

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

1. Are you sure, that your example is correct 2,15,4 which = 2,3,4 ... and not 16 = 3?
2. You don't check the case, when you get, for example 4,2,3. In that case your (x == 2) and (ex == 1), but it is still Straight.
P.S. If the first part of your problem (I mean thread "determine type of card hand") is solved, mark it solved, please :)

Antenka 274 Posting Whiz

This error caused by whitespace between '_' and 'minTemperature' here:

_ minTemperature= minTemperature;
Antenka 274 Posting Whiz

Also, you have interesting name for variable, that keep returning value ('nothing'). If you want return nothing from method, you should use void keyword.
For your code it's:

public static int divArry( int numbers [])

turns into

public static void divArry( int numbers [])

And print information directly from your method :)

Or specify more proper name for that variable.
P.S. It's not obligatory, but I think that can make your code better :)

Antenka 274 Posting Whiz

Hello, hypocrisy.
For keeping distinct numbers, you can use, for example Class ArrayList<E>. This class contains method to check, if the list already contains given element.

Antenka 274 Posting Whiz

When you call GetFiles method, it return to you an array of strings (filenames). To show them in the message, you should organize them in way, that you like into a string. After that you can see here a bit about showing messages: MessageBox Class

Antenka 274 Posting Whiz

Direcrory class placed in System.IO. So you sould add import to it:

using System.IO;
Antenka 274 Posting Whiz

You can use foreach cycle. E.g. like this:

foreach(string fileName f in Directory.GetFiles("SomeDirectory"))
{
    ...
}
Antenka 274 Posting Whiz

Sure, you can, e.g. using method LastIndexOf() to find the last slash character in the returned string ... your folder name will be placed after the last slash.

Antenka 274 Posting Whiz

Hello, gallian99.
This may help you: OpenFileDialog Class - that for case if you're not dropped it on your form.
and this: Opening Files Using the OpenFileDialog Component - if it is on your form.

Antenka 274 Posting Whiz

If I were you, I would probably do that:
1. Create a class, that will represent a single card (it will contain rank, suit). I suppose it will be better to use enum to list all possible suits and ranks.
That class can contain constructor, that will generate some card. And this class can contain equals method to compare 2 cards. With equals method you'll check if the card was already generated.
2. Next you'll need check appearances of some card combinations. For that you can create methods in some else class (that will contain methods, to check a list of cards for all possible combinations that you need - flush, pair ....). Also in this methods you shouldn't 'think' about position of the card (here you do that: (x==1) ) ... for alternative, you could use, for example some 'flags' for each card in hand.

Antenka 274 Posting Whiz

Hello, javaman2. You have mistake in logic here:

if(((x==1)&&(cardSuit==0))&&((x==2)&&(cardSuit==0) )&&((x==3)&&(cardSuit==0)))

All that expression contains only '&&' condition. So if a bit transform it, you are telling: do something, if that condition turns true (x==1) and (x==2) and (x==3) .... Also there are same mistakes in similar expressions. I suppose, that it must be 'or' between pairs of expressions: ((x==1)&&(cardSuit==0))||((x==2)&&(cardSuit==0) P.S. I'm also have some advices about organization of your prog. If interested - ask :)

Antenka 274 Posting Whiz

I have a little variation on your 'old' code. It is not the best solution, but it is better than nothing. You can analyse it and make summary for yourself:

public void fillBoard()
    {
        int i=0;
       //number of added numbers into row
        int colAddedCount = 0;
        //go through every spot on the board, placing a number in each one.
        for(currentRow=0;currentRow<ROWS;currentRow++)
        {
            currentColumn = 0;
            //'While' cycle instead 'for' to we have ability to change currentColumn inside it
            while(currentColumn<COLUMNS)
            {
                    //the column number for adding numbers into table
                    int col;
                    do
                    {
                        do
                        {
                            num = randy.nextInt(9)+1;
                            number = String.valueOf(num);
                        
                        //cycle untill we find number, which is not in the row
                        }while(isAlreadyInRow(number,theBoard[currentRow]) == true);
                        
                    //finding a valid column for our number
                    col = validColumn(number, theBoard, currentRow);
                   //about this: look later ...
                    if((colAddedCount == theBoard.length -1)&&(col==-1))
                    {
                        //clearing the whole row to fill it again
                        clearRow(currentRow, theBoard);
                        //reset the count of numbers, already added into row
                        colAddedCount = 0;
                        //resetting current column to refill the row
                        currentColumn = 0;
                    }
                    //if method validColumn returns '-1' it means, that we have to generate new number
                    }while(col == -1);                    
                    // after the number is allowed to be placed there, place it there.
                    theBoard[currentRow][col] = number;
                    //after adding new value to row we increasing the count of already added values
                    colAddedCount++;                    
                i++;                
                currentColumn++;
            }

            // after a row has been filled, reset i
            i=0;
            // after a row has been filled, reset colAddedCount
            colAddedCount = 0;
        }
    }

//clearing the row of the table …
llemes4011 commented: Thanks for the code, works great :) +1
Antenka 274 Posting Whiz

So your question is solved? If so, please mark thread as solved :)

Antenka 274 Posting Whiz

Hello, llemes4011.
Hm ... interesting task. Your problem here:

// If the number already appears in the row and the column, change the booleans to false to check again
if(number.equals(theBoard[i][currentColumn]))   legal[0]=false;
if(number.equals(theBoard[currentRow][i]))      legal[1]=false;

Here you should check, whether your element is already appears in row and column (from your words) ... and all that you do is comparing it only with 2 elements of your 'theBoard'. That is why you have repetitions in your result 'theBoard'.

Antenka 274 Posting Whiz

Just to add Ezzaral: you have interesting situation:
1. You declare a variable:

private static newTEST newTest;

2. Then you call this:

TUImain tui = new TUImain(newTest);

what means, that you call the constructor and pass this variable into it as parameter.
3. In constructor you do this:

this.newTest = newTest;

what means, that you assign the variable of your class with parameter that was passed to constructor (which is the same variable O_O).

So ... to escape such situation you should or specify a new variable of type newTEST and then pass it to constructor;
or make some changes to constructor (maybe fill by standart values).

About throwing exceptions: for example you have such declaration of method:

private void returnWord() throws Exception

it means, that this method can throw an exception, but it is wouldn't be caught in it. It is like warning: "This method, that can throw an exception of type Exception. If you'll call it, process the catch block for it".
Considering that and that that main method is entry point of the program, think about this:

public static void main(String[] args) throws Throwable
Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

i think it would be much nicer to call the method with a value, which relates to what happens in recursion,

sure you are right!!!

and please don't misunderstand, but i would recommend you to look at the previous posts, and go into the topic, before y<ou post before

I have read all post in this thread. But misunderstood ... I thought you want have as smallest triangle - the smallest visible triangle (or direct set depth of recursion).
In this case, the variant with 1 condition is the best :)

Antenka 274 Posting Whiz

As minLineLength I mean minimal line legngs (you should specify it yourself - the "12" it is an example) ... not only by x or y coordinates.
Using this additional condition you can specify wittingly big depth of the recursion and It is stops, when you reach the minimal triangle, that you specify.
Also I can't give advice about determining the depth of the recursion mathematically ... as you say it depends on screen resolution.
To count the levels, you can create variable in your class ... and then specify it, when you will go out from recursion:

if ((level == 1) ||(minLineLength < 12))
{
//here
}

It value will mean a count of levels, which were remained after doing one branch of your recursion ... here what I mean:

//you call your method with 8 length
drawFractal(8,g, A, B, C);
....
//if we reach the condition (because our screen resolution doesn't allow us to draw more triangles - as you specify) for example level=2
if ((level == 1) ||(minLineLength < 12))
{
//here we set the value, that will remember the leves remained to do
}

What we have: 8 - 2 is a depth of one branch ... also each branch creates 3 new branches ... here is your solution.
Maybe there is a better way to describe that - but It is my variant :)

Antenka 274 Posting Whiz

You can add this condition to this:
for example

if ((level == 1) ||(minLineLength < 12))
Antenka 274 Posting Whiz

Hello, jrobw.
You asked:

or how do I determine, how many levels of recursion I actually need???

You can offer to user to enter this. And then pass it as a parameter into method.:)

Antenka 274 Posting Whiz

Maybe you should try to do this:

writer.flush();

P.S. And in conclusion, don't forget to close your writer after working with it :)

Antenka 274 Posting Whiz

ooops :)
sorry for misleading

Antenka 274 Posting Whiz

Hello, amgupt01
You can use this:

PrintWriter writer =new PrintWriter("yourfile");
writer.println("Line to print");
Antenka 274 Posting Whiz

Hello, mrjoli021
I hope the Sun description of Runtime class help you:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html

Antenka 274 Posting Whiz

Hello, shubhang.
You've asked:

pls help me with the logic of displaying it on the same line.

Here is a few articles about positioning cursor in console application:
http://mindprod.com/jgloss/console.html
http://en.allexperts.com/q/Java-1046/java-positioning-cursor-console.htm
http://www.rgagnon.com/javadetails/java-0469.html
Hope it can help :)

Antenka 274 Posting Whiz

Hello Sandawg,
Your thread name is "Printing array contents". If this question is already solved, please mark it solved. About sorting: try to do it yourself, if there are will appear any troubles - create new new thread, describe it (problem) and someone will help you.
Good luck :)

Antenka 274 Posting Whiz

Just to add to what I and Stultuske are saying, here is an example for you:

You have method:

public static void printArray(int count)	
{	 
         for (int i=0; i<count; i++ )	 
        {
               System.out.print(pName[count]);
               System.out.print(iNumber[count]);
               System.out.print(iStock[count]);
               System.out.print(uPrice[count]);
               System.out.print(tInventory[count]);		  
        } 	  
        System.out.printf("%s$%.2f\n", "Entire Inventory Value: ", totalInventory);	  
        System.out.printf("%s$%.2f\n", "Entire Inventory Restock Cost: ", totreStock);	
}

(And now try to look at this code not as autor, but as exterior watcher)
Looking on this code, you can't say exactly that you are printing contents of one single object "Product". I see arrays (iNumber, uPrice etc.) but I don't see any connection between them.

Let's see what would be happend, if you will do like Stultuske said:

//we are defining class
public class ProductNew
{
      //with some private declarations, setters, getters etc.
}

//and here we have class Inventory
public class Inventory { 		
public static void main(String[] args)		
{
        //creating an object of newly defined class.
        ProductNew[] warehouse = new ProductNew[maxlength]; 

        //some code

      //and if you ever want to print contents of your array, you'll write:
     for(i=0;i<count;i++) 
    {
             System.out.print(warehouse[i].pName); 
             System.out.print(warehouse[i].iNumber);
            // and so on...
    }

Here is this bond: the fields pName and iNumber are belong to object warehouse (wich is single "Product").
It's not the best example to show abilities of object-oriented language, but It's based on your code, I hope It's more understandable, than my previous post :)

jasimp commented: Very helpful +9
stultuske commented: just because I was to lazy to put in an example :) but if everyone did what I told them, the world 'd propably have come to an end by now ;) +3
Antenka 274 Posting Whiz

Hello, Sandawg.
Beforehand sorry for my english .... :)
Here is my recommendations. Yoy must try to use static variables not so much as you do :) One of the classics said (If I'm not mistaken, it was Troelsen) "Hide everything that you can hide". If you need to wide the using of your variable, you could quickly do it. But if you want to hide everything else, it take much more time.
The "life" of static variable starts, when you are declared it. Like a class. After you declared it, you can use it. Also it's says "the static variable has class level".
And also, about your data: sharply defined you can see the object, with some data grouped in it. So you can create a class, that will contain a data and operations, that you can do with this data. :)
Maybe it seems unnecessary, but try it. You use object-oriented language and do not use it abilities. After a couple times you'll understand that it is really comfortable thing :)