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

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

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

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
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 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 :)

Antenka 274 Posting Whiz

I saw. But this try didn't helped me to read normally his code. ;)

Antenka 274 Posting Whiz

Hello, Sandawg.
Here is your mistake: you trying to take element of array, that not exists.
you should use this

public static void printArray(int count)
{
for (int i = 0; i<count; i++ )
{
System.out.print(pName[i]);
...
}

Also there is a couple recommendations to you (including about using static keyword). Ask if you interested.

P.S. If you post your code in more readable state next time, you get the answer much faster :)

Antenka 274 Posting Whiz

You should realize interface Comparable in your class Person. After that you'll can compare your objects, like that:

Person a, b;
a = ...;
b=...;
a.CompareTo(b);

This will allow you to sort your array of Person. And also it became Comparable.

Alex Edwards commented: Comparable is the way to go! =) +5
Antenka 274 Posting Whiz

Here is link to understand Comparable Interface:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html

And here is a little help on binary search:
http://leepoint.net/notes-java/algorithms/searching/binarysearch.html

Antenka 274 Posting Whiz

I've tried to run your code ... it's working. Try to rebuild your project.

Antenka 274 Posting Whiz

You can use scanner.next() it returns string, but you can convert it to char.

Antenka 274 Posting Whiz

Scanner has no definition of method getChar.

Antenka 274 Posting Whiz

You can output them:

System.out.println(application2.setHours(input.nextInt()));

or check, if the setting passed correctly

if(application2.setHours(input.nextInt())))
{//all good}
else {//something wrong}

Also you can save that value to variable:

Boolean settingStatus = application2.setHours(input.nextInt()));
Antenka 274 Posting Whiz

Correct me, if I'm wrong:
1. You creating new "clock" and setting it to 0.

Time application = new Time();
application.TimeTest(0, 0, 0);

2. Then while setting the hours creating 2 more clocks.

Time application2 = new Time();					application2.setHours(input.nextInt());

and

Time app = new Time();
app.getHours();

Here is your problem: you setting hours to the clock-2 and getting it (hours) from clock-3.

Antenka 274 Posting Whiz

As I understood, you have combined information in your file "books.txt" (name -
string and price - double). To split information, that was read from your file you should use patterns (in example there is pattern to delimit using comma and different number of whitespaces " *" ). You also can use control symbols, such as "\n".

//we have cycle until we'll reach the symbol,
//what hasn't next element
while(src.hasNext()) { 
      //if next value is double
      //(it is just checking next value, not goes to it)
      if(src.hasNextDouble()) { 
	//we take this value and add to sum
        sum += src.nextDouble(); 
      }
      //if the next value is not  double
      //in your case you should pass through this block
      else { 
        //we take this element as string
        String str = src.next();  
        //if this string equals("done"), we are
	//coercive breaking the cycle
        if(str.equals("done")) break; 
        else { 
          //if this is not "done" we have troubles :)
          System.out.println("File format error."); 
          return; 
        } 
      } 
    }

Did I answered on your question?

Alex Edwards commented: Quite the helpful individual =) +5
Antenka 274 Posting Whiz
Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

Beforehand, sorry for my english...
The || - is short version of |.
I.e. if you have simple condition like this:
(a||b) then, there is no difference, what operator to use. In case with complex condition:
((a==b)||(c==d)||(e==f)) will be difference. The || operator will be checking the conditions, untill it find TRUE. If it happened on (a==b), the other conditions will not be checked. If you are choose the | operator, then all conditions will be checked necessarily.

Antenka 274 Posting Whiz

No, there is no necessity. I just forgot, that I can create my own :)

Antenka 274 Posting Whiz

Can you attach whole file m3u, that you are working with?

Antenka 274 Posting Whiz

ReadLine() is not the only one, there are a few not less interesting functions in StreamReader class ... pay attention to it.
And there's a few functions in Stream class (for example to move the cursor).

Antenka 274 Posting Whiz

If the files that youll working with will be not to large, I think, you can use It. But in case bigger files, I prefer to use, for example, ReadLine() function to reach the end of file.

Antenka 274 Posting Whiz

:) good luck

Antenka 274 Posting Whiz

I can offer you this:
String.Concat(s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));

where s - is title. Not the best, but it is variant.

Antenka 274 Posting Whiz

How about splitting like this:
string[] s1 = s.Split(new string[]{".mp3"} ,StringSplitOptions.RemoveEmptyEntries);
and then Split('-') ?

Antenka 274 Posting Whiz

beforehand, sorry for my english... :)
I have some advices for you:
1. You have a lot of repeating code in your program. You should take out it to a method(s) and then call it...
(also in doneBtn_Click method you have switch operator, that no matter what do this: amountTxtBx.Text = ""; you could place this before of after switch)
2. And you can make you switch operator shorter (it has equals cases)
3. Instead of creating variables chckFee, interestRate I would create an accessors in classes to get them.
I think, that's all for a first sight.
4. Instead caseNumber you could use an enum, with work, you want to lock in. I think it would be more understandable.

schmidty169 commented: Took advice and took out repeative code and placed into methods. +3
Antenka 274 Posting Whiz

Here is something, that I found in your theme:
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2008-04/msg00629.html

:) I hope, it will help you!

ddanbe commented: Thanks for the help +2
Antenka 274 Posting Whiz

Try type this:
csc nov8prac1.cs classinprac1.cs

or csc *.cs (to include all files in folder)

Antenka 274 Posting Whiz

Beforehand, sorry for my english...
Method classinprac2() declared as static, so to work with him you shouldn't create object of class classinprac1.
This is right:
ov8prac1.classinprac1.classinprac2( );

Antenka 274 Posting Whiz

Beforehand I'm sorry for my English...
I don't know any way to dynamically create variable, but I can offer some alternatives:
1. Use Dictionary
2. Create class variable dynamicly