Antenka 274 Posting Whiz

Hi, hwoarang69.
I'm not able to test your code right now, but I'll take a shot to guess, where's the problem sits. It can be in this method:

public void actionPerformed(ActionEvent e)
{
    //all collsion stuff go in here
    repaint();
}

just check, how many times it been called every time when you perform an action.

Take a look a these few links .. I guess, there're some good info and examples:
Java applets
CA597 Tutorial - Simple Applets
javax.swing.Timer

Antenka 274 Posting Whiz

I just would like to add something about using methods.
You can easily break up your code into methods by simple describing what it does. E.g. "Method takes user input and makes a roll and builds a histogram ...". The activities, separated by "and" word may be easily moved into separate methods (see the link in the end of my post).
One method should be responsible for only 1 operation and it's name should describe it's behavior. If your method name looks like it's too long ... take a closer look, if it can be divided into a few.

Take a look at this article: Single responsibility principle

Antenka 274 Posting Whiz

Hi there!
I'm still under inspiration of reading one more book about good coding practices, so ... I just can't passy by quietly :)
I'd like to give a few notes about this thread:

First.

Programming is all about complexity management. So, if you have a task to make a 1-dimentional array with a sits 1-5 for an economy class and 6-10 for business, there's no need to try to guess all possible usages for your code. It can be way different from "11-seats plane". Why can't it be train ... with 3 classes. Same sits booking, but we have extra class and a few "fuselages". It's a simple book-assignment ... moreover, there're still a pretty big bunch of interesting topics, that isn't covered yet (including enums, complete information of class usages etc.) ... C'mon guys, hwo's ready to build up a commercial booking application using only 1-dimentional arrays with no classes and enums? ;)

Of course, in real-world programming, you should think of possible ways, but they're as usual must be
fully documented as your assignment. And you should code them maximally close to that wording.

It's just another side of medal. Haven't anyone faced such situation, when you ask "code me a method, which sum's a two numbers". A few days you hear nothing from developer. And then, on the 3rd day, you get a all-in-one method-calculator with a huge bunch of incoming parameters, indicating the operation, additional params etc. etc. ... isn't it funny? …

Antenka 274 Posting Whiz

Ok .. suppose, we have entered a text, that consists of 2 letters.
What would we have here:

for (int p = 0; p <= tbname.Text.Length; p++)

Here, we will iterate from 0 to 2, ie:
we will take tbname.Text[0], tbname.Text[1], tbname.Text[2] .. doesn't look weird for you? :)
Try it yourself: enter 2 letters and debug this thing. And post here your original string and the thing that you have under tbname.Text[2].

A magician never tells

I just want you to find your solution by yourself .. I'm just trying to lead you in a right direction ;)

but still not working

Try the thing, that I said upper in this post. Fix a bug, if there is any .. and .. I'm waiting for your results ;)

Antenka 274 Posting Whiz

do you mean for the "ForeColor"?

Exactly. Know why? Because:

((int)(((byte)(60)))

it's the same as

60

Also, tbname.Text.Length + 1 . Why plus 1? Count how many times it would iterate if your string would be, e.g. 2 symbols length.

It doesnt pick up when a number is entered and it doesnt do anything when a number isnt entered. I dont get it :\ this code just doesnt seem to work at all

Answer the previous question, cause it may throw an exceptions to you (I would be surprised, if it's not :)). That may be cause a problem.

P.S. Char.IsLetter(n) works pretty good in here, and determines a strings also as the others symbols.

Antenka 274 Posting Whiz

The scope of visibility of a j is between {} of you cycle. Because it was declared in the for-cycle.

You have 2 ways to go:
1. Move declaration to a higher level to extend the boundaries, where this variable can be visible.
2. Save the value of j variable in a different variable with a larger scope. And then work with it.

Antenka 274 Posting Whiz

Hello, farshadak2004.
Take a look at this: Getting the user idle time with C#

Antenka 274 Posting Whiz

Hello,
as MSDN says,

Control.Bounds Property: Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

and

Control.Location Property: Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

If you're ok with a Location, you probably should use it. If you need something more than upper corner coords - use Bounds :)

Antenka 274 Posting Whiz

Hello, walid86.
Firstly, try it out by yourself:
1. Find your local folder called "My Documents".
2. Right-click on it and go to tab "Location".
3. See what's in there ;)

Next, it would be great if you posted exception message (so I don't need to recreate all the behavior to reproduce your exception), cause Win32 Exception is too generalized term.

Ok, closer to your exception. I have a few questions:
1. Where do you get it? (exact line of code)
2. What data is in variables, on that line?
3. What's this for:

int index = this.listBox1.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)

it's look like it should be

if (listBox1.SelectedItem != null) {
}

or

if (listBox1.SelectedIndex >= 0) {
}

.. but that's just a thoughts in a loud .. maybe there's something that making you use IndexFromPoint .

Antenka 274 Posting Whiz

Hi, adobe71.
C# uses the backslash to escape characters, so "\\" is equal to \ literal, and "\" results in error, because you trying to escape the second quote and your string literal remains "unclosed".

You have 2 ways to go:
1. As you can see, double backslash results in a single one. So, to have \ ? you have to write \\ . 4 backslashes to result "\\" .. and so on.

2. You can use @ before your string literal, so the compiler won't try to get the control sequences from your string (based on the backslashes) and would treat your string same, as you write it (so the @"\" results into \ ).

ddanbe commented: Good advice! +14
Antenka 274 Posting Whiz

Hi,
if you're talking about windows forms, then you might be interested in viewing this thread: How do i make MDI Parent & Child Forms in C#.NET as looks like as Master & Child Pages in ASP.NET?

Antenka 274 Posting Whiz

Momerath, thanks for correcting.
Probably, shouldn't multitask while posting :D

NewOrder commented: thanks for the help +0
Antenka 274 Posting Whiz

Hello,
yeah, static word might be confusing for some time. But it's not that hard .. Static members has a class level, rather then object one. To understand it better, let's look at example. Imagine a form for making cookies ..

Your form is your class. And your cookies are your objects.
If you change your form once, it would affect all the children .. so the line:

color = colorParam;

means "May all MyRectangle objects would have a given color" .. all the objects, no matter if they were created before or after this call (of course, this for the case, when the color variable is static).

Ok, and now, correct your code, knowing all this .. or ask if something left unclear :)

ddanbe commented: He! Nice explanation :) +8
kvprajapati commented: Helpful! +11
Antenka 274 Posting Whiz

Hello,
I might help if you would follow these forum rules, as "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."

So, tell me, please what you've already tried, what you can't understand or what troubles are you facing while coding this task?

Lusiphur commented: Good Post! +1
Antenka 274 Posting Whiz

Ok, let's start from the beggining ...
The task is make a WPF application. What we usually expect from server - is performance. From client we usually expect usability, attractiveness, etc. (also performance, but less than from server). So it would be logical to make a server part of an application as Console application (as adatapost mentioned). And the client part would be a WPF application. So let's describe the basic behaviour for both parts:
Server:

  1. Start
  2. Waiting for the client to connect
  3. Process client
  4. Goto step 2 if we're going to proceed, and goto step 4 if we're done
  5. Stop the server

Client:

  1. Connect to the server
  2. Interact with server
  3. Close connection to not occupied server for too long

So now you should make 2 applications (the Console one and WPF one for the server and client respectively). I would suggest you to create them within one solution to ease the control of them.

Ok, now we have basic algorythm and 2 empty projects created. Now - closer to code .. I've changed a bit the client and server part .. Let's start from server:

static void Main(string[] args)
        {
            //The IP adress of computer, where server is running
            IPAddress ipAd = IPAddress.Parse("127.0.0.1");
            //Initialize listener on given IP and port
            TcpListener myList = new TcpListener(ipAd, 8001);
            //Start Listening at the specified port
            myList.Start();
            Console.WriteLine("The server is running at port 8001...");
            Console.WriteLine("The local End point is :" + myList.LocalEndpoint);

            //Endless …
kvprajapati commented: Greate Explanation. +9
Antenka 274 Posting Whiz

Hello, you have interesting problem ... let's see:

Does this make the slightest bit of sense?

Well, that depends on from which view to look at this:

  1. It sounds logical, when you declare in base class, that it or it's children would implement DataComparable. But since the base class is abstract - we're not forced to implement everything "right here and right now". Especially, considering, that you gonna compare some child types and base class shouldn't be aware of it's children.
  2. From other view - the base class contains all common and necessary
    members, that should be in the child classes. Considering, that in your case the base class is abstract, it can provide a full realization of it's methods or let the child classes implement them by itself. So it would be a bit confusing to gather all information about the base class in it's inheritance hierarchy. That's probably why you should provide at least signature of all non implemented yet members.

Now - closer to your problem. Indeed, your variant of that java piece of code look a bit strange. So we must to redesign that a bit...
Just to be sure .. are you sure, that for your case StringDatatype and NumericDatatype should have same base class? (Even in C# they derived from System.Object and System.ValueType respectively). Maybe they have more differences, than commons? .. Or maybe just problems in an example ..
Ok, if inheritance from that base class is …

Antenka 274 Posting Whiz

Hello,
I just want to share some thoughts to consider on your problem.

About suggested ways to go:

1. Leave it as it is it works but is inefficient

I think this solution has it rights to exist for the case when your collection has small size. But it isn't true for your case, so we're moving on. It would provide faster access to your data.

2. Create a 'master' defectcollection, preload it with all the defects and reference them

Well, same as for previous case - you can freely use it, when don't have too many data.

3. Write an defect collection that loads defects as required and allows multiple release objects to reference them

I think that is a step into right direction .. using less memory and still keeping it fast.

4. Write the defectCollection as a lazy collection populated only when it is referenced

I think it's the best of suggested solutions. Since your application isn't real-time system - you freely can make your user wait few more seconds (or even milliseconds) to load requested data. Moreover, if I were you - I categorized the defects on groups .. even made some structure of them to lessen the amount of information needed to load each time (also it can help to navigate between those defects). And place all this into e.g. lazy loading tree. (It can be whatever you want .. one more example would be a paged table, which loads …

kvprajapati commented: Good suggestion. Helpful. +9
Antenka 274 Posting Whiz

Oh, my! Might be, but wasn't good enough. How could I miss that OraLocaleInfo ? One more stupid mistake in my list :D

Thank you sooo much

kvprajapati commented: Great! +6
Antenka 274 Posting Whiz

Okies. Now the points of attention in the given example:
ComboBox creating ..

this.ComboBox1 = new System.Windows.Forms.ComboBox();
...

Now to be able to catch and process the events , raised in your combobox in runtime, you should add event handler to it:

// Associate the event-handling method with the 
        // SelectedIndexChanged event.
        this.ComboBox1.SelectedIndexChanged += 
            new System.EventHandler(ComboBox1_SelectedIndexChanged);

Ok, now we have ComboBox, with event handler attached to it. Now all you have to do is implement the logic of this method, which will be raised as soon as Selected Index in your Combobox would be changed. Here's what the example gives:

private void ComboBox1_SelectedIndexChanged(object sender, 
        System.EventArgs e)
    {
        //obtain ComboBox, which was raising this event
        ComboBox comboBox = (ComboBox) sender;

        // Getting selected item from it
        string selectedEmployee = (string) ComboBox1.SelectedItem;
         
        // Working with other controls on the form
        TextBox1.Text = TextBox1.Text+ "\r\n" + selectedEmployee + ": "
            + count;
    }
Antenka 274 Posting Whiz

Hello.
I'm not sure if this is what you're looking for, but to get array of child forms, you can use the MdiChildren property, e.g.:

this.MdiChildren[0].BackColor = Color.Black;

//and in same manner for sub - sub child forms
this.MdiChildren[0].MdiChildren[1].BackColor = Color.Black;
Antenka 274 Posting Whiz

Ok, let's take an example:
137*1456

We can factorize it:
137*(1000 + 400 + 50 + 6)

To see the connection, we can convert this in form like this:
137*(1*10^3 + 4*10^2 + 5*10^1 + 6*10^0)
(where ^ means powering)

So, depending on the position of the digit in the number, we can represent it in such view (see above).

so, what we have:
137*1456=137*1*10^3 + 137*4*10^2 + 137*5*10^1 + 137*6*10^0

All you have to do now - is extract algorithm from this and code it :)

ddanbe commented: Clear explanation:) +5
Antenka 274 Posting Whiz

I understood you.

so in the loop i set the size of sum as ( sumsize -1 ) because in adding we add from right to left and the first added number will located in the most significant location of the array
and then at the end of the loop i decrement the sumzie to move left to the next location of the array, and because that the sum array is bigger that the longer number by ( 1 ) location , there will be a place to the carry at the least significant location.

That's pretty clear, but also, from your words: you go through arrays and their length is 1 less than sum array has. So the first element of this array would never be changed. So, that's why I gave you a piece of code, that assigns that first element (if necessary).

About this:

about the last point ( 1.
for(int i=0;i<sumsize;i++)
)i cant see anything wrong in it
i did this because i want to display the elements of the sum array which is still wrong

after previous cycle (where you sum your numbers) the value of sumsize would be 1 (in any case). So you would should do something like this:

for (int i = 0; i < sum.Length; i++)
Antenka 274 Posting Whiz

Hello.
The troubles are starting here:

carry = 1;

You carry can be more than 1 .. so you should take the integer part of your holder:

carry = holder / 10;

Now, after summing all the numbers - you can still have something in your carry variable .. and shouldn't waste it:

if (carry != 0)
            {
                sum[0] = carry;
            }

And one more mistake, or rather typo:

for(int i=0;i<sumsize;i++)

You just were increasing sumsize in cycle... So it won't be the actual size of the sum.

sknake commented: excellent +6
Antenka 274 Posting Whiz

Hello, Ryshad :)
Ok, let's go .. I'll give a few comments on your suggestions and then give you an example.

a) include a flag in the bay to show that it is in another step

No, you shouldn't. Because the Bay class shouldn't be aware of what's happening outside of it.

b) have the step check with the sequence to see if any steps contain it

Also sounds a bit weird .. if rephrase - it would be "the element of an collection should be aware of other elements in collection "

c) check in the main form and pass a colour to the draw method

That's seems the right abstraction level for that design. The Form contains the collection and can be aware of what stored in it. But, probably not passing a color, but calling the right method or calling method with parameters.

Ok, for the first sight that all may seem kinda confusing, but here's example:
Imho, the one of the best methods of explanation - is use of metaphors...

Let's imagine that class is a closed box. If you're inside that box - you can't see what is happening outside (see your a suggestion).

But if we outside the box - we can see some of it characteristics (the methods or data, that you opened for public viewing aka open interface of the class).

Now let's put a few boxes in a row .. we have now a collection …

Geekitygeek commented: great explaination :) thank you +1
Antenka 274 Posting Whiz

Hello.
If I understood you correctly - this may be helpful for you: Implementing Singleton in C#

ddanbe commented: Nice suggestion:) +5
Antenka 274 Posting Whiz

Hello.
Isn't this non-stop recursive call to the same function:

public string GetClientsList()
        {
            try
            {
                Thread.Sleep(1000);
            }
            catch (Exception e1)
            {
                Console.writeline(e1.ToString());
            }
          return Program.ServerForm.GetClientsList();
        }
sknake commented: probably :P good catch +5
Antenka 274 Posting Whiz

Hello, phoenix_dwarf.

While playing with your code found interesting thingy: it works fine on every tab .. except the 1st one. Anyway, while trying to explain such behaviour, found this:

Note:
Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.

So, this should work fine:

tabControl1.SelectedIndex = 0;
txt_CLName.Select();
Geekitygeek commented: nice catch, i learnt something too here :p +1
Antenka 274 Posting Whiz

You're welcome :)
Good luck with learning C#.

Please, mark this thread as solved if the issue is settled.

DdoubleD commented: Spiritually optimized....Awesome!--jk, good job! +4
Antenka 274 Posting Whiz

Hello.
Both ArrayList and List classes are provided to work with dynamic arrays. But, in ArrayList all elements have type of System.Object. And in List you specify the type of elements by yourself. Let's see what it gives to you:

1. Suppose, you have an array of strings.
For ArrayList: while adding new element to array - it will be
cast to an Object type and then added to list. Then to take the
value of it - you'd have to cast it back to String.

ArrayList list = new ArrayList();
            list.Add("String element");

            string element = (string)list[0];

For List: you're just define a List of strings and there's no need
in boxing/unboxing operations (casting to Object type and back).

List<string> otherList = new List<string>();
            otherList.Add("String element");
            string otherElement = otherList[0];

2. Since the every reference type can be cast to System.Object and every value type can be boxed into an Object, it's possible to have something like this (in ArrayList):

ArrayList list = new ArrayList();
            list.Add("String element");
            list.Add(2);

The List<T> is strong-typed, so it's one more advantage. E.g. it wouldn't allow you to add Integer in your list of Strings. You will be warned at compilation time that you're trying to do something illegal.

List<string> otherList = new List<string>();
            otherList.Add("String element");
            otherList.Add(2); // compilation time error

3. And here's a nice post, where performance of List And ArrayList was compared: ArrayList’s vs. generic List for primitive types and …

sknake commented: Great explanation +17
ddanbe commented: Nice and clear explanation :) +14
Antenka 274 Posting Whiz

Hello, DeOiD.
Here's one more way to go ..
If choose between Array, ArrayList or List<T> - I would suggest you use List<T>.
For keeping such values you can define a class or structure. For example:

public class Result
    {
        int rowNumber;
        string fieldName;
        string value;

        public Result(int rorNumber, string fieldNumber, string value)
        {
            // assign variables
        }
    }

if you have a few types of results, you can create more classes/structures ...

public class Result2
    {
        int rowNumber;
        string fieldName;
        string value;
        string whatever;

        public Result2(int rorNumber, string fieldNumber, string value, string whatever)
        {
            // assign variables
        }
    }

We know, that List can contain the elements of same type. So we should find the connection between 2 created classes:
1. Both classes (also as all reference types) are inherit from System.Object.
2. You can define the parent class for them by yourself.

What it will give to you? After that you can create a List:

List<object> resultSet = new List<object>();
.. or
List<SomeBaseClass> resultSet = new List<SomeBaseClass>();

and add elements to it:

resultSet.Add(new Result(1, "someName", "someValue"));
resultSet.Add(new Result2(1, "someName", "someValue", "something else"));

Depending on what way you'll choose - the new element of resultSet would be automatically converted to either Object or SomeBaseClass .

And then to determine, which type of result you currently working with - use is or as keywords.

sknake commented: good samples +17
DeOiD commented: really nice +3
Antenka 274 Posting Whiz

Hello, wil0022.
Indeed, you can't do like this:

if (final[0] & final[1] & final[2] & final[3] & final[4]  & final[5] & final[6] & final[7] & final[8] & final[9] != first[counter2])

I suppose this construction means "If first[counter2] isn't in the final array .."

If so - then the problem can be solved, e.g. by using nested loops:

// the number of distinct values found
            int numberOfDistinctNumbers = 0;

            // external loop will go through the entire First array
            // to check if the value already exist in the Final array
            for (int counter = 0; counter < ten; counter++)
            {
                // true - if the value of First[counter]
                // already exist in array
                bool alreayExist = false;

                // then we go through the Final array
                for (counter2 = 0; counter2 < numberOfDistinctNumbers; counter2++)
                {
                    // After the first occurrence of the value of First[counter]
                    // in the Final array - we setting the alreayExist to
                    // true and going out of that cycle
                    if (first[counter] == final[counter2])
                    {
                        alreayExist = true;
                        break;
                    }
                }

                // If we haven't found any occurrence of that number
                // in Final array - then it's distinct and we're adding it
                if (!alreayExist)
                {
                    final[numberOfDistinctNumbers] = first[counter];
                    numberOfDistinctNumbers++;
                }
            }
serkan sendur commented: turkish always support ukrainian +10
Antenka 274 Posting Whiz

Hello.
I was playing with your code. Here's what I've got:

// selecting some text in RichTextBox
...
Clipboard.SetText(richTextBox1.SelectedRtf, TextDataFormat.Rtf);
sel.Paste();
Antenka 274 Posting Whiz

Yeah .. it also works fine here.

P.S. Are you sure, that your file, which lays in path has text in it (maybe this is that simple, that you're overlooking :P)?

Antenka 274 Posting Whiz
kvprajapati commented: Well said. +7
Antenka 274 Posting Whiz

Hello, HBMSGuy.
Are you sure, that you have error about passing derived class when method asks the base one? Only thing, that I see it's a few mistakes (in other area):

Class TaskToRun
{
     public virtual void run ();
}

here if you don't specify any functionality to the method 'run', call the calss (also as this method) as abstract. Or add empty brackets pair: { } - if you want to leave it as virtual.

Class SayHi : TaskToRun
{
    public run()
    {
        Console.WriteLine("Hi");
    }
}

if you decided to make your base class abstract, you should add 'override' keyword to method run . Also the return type is also needed :P
if you decided to leave your method in base class as virtual - you have 2 ways to go:

Warning 'SayHi.run()' hides inherited member 'TaskToRun.run()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.

RunTask(TaskToRun task)
{
   delegate void MethodToRun();
   MethodToRun methodtorun = new MethodToRun(task.run);
   methodtorun();
}

The delegate declaration should be at class level (like you would declare variable in the class) .. or higher - in namespace. You decide.
Also there're some notes about initializing and calling it. Look here, there is good example: delegate (C# Reference).

Well, here's what we have in result (my version):

delegate void MethodToRun();

class TaskToRun
    {
        public virtual void run() { }
    }

class SayHi : TaskToRun
    {
        public override void …
Ramy Mahrous commented: Ideal answer (Y) +7
Antenka 274 Posting Whiz

Well, let's look closer to example given there (I mean the points of attention):

//create a model
final DefaultListModel model = new DefaultListModel();

//creating JList based on our model
JList list = new JList(model);

//add element to the model
model.addElement("Element");

This 3 lines describes all the process: working with JList using model (look at MVC pattern).

So, we can make this example even more simple:

public static void main(String[] args)
    {
	final DefaultListModel model = new DefaultListModel();
	JList list = new JList(model);	
       //adding 2 elements
       model.addElement("Element 1");
       model.addElement("Element 2");


	JFrame frame = new JFrame("DefaultListModel JList Demo");
	JScrollPane scrollPane = new JScrollPane(list);
	frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
	frame.pack();
	frame.setVisible(true);

    }
peter_budo commented: Nice examples +17
Antenka 274 Posting Whiz

Hello, ddanbe. All you have to do is add your BinCB to the list of Controls of your form:

this.Controls.Add(this.BinCB);
ddanbe commented: I could have known this but thanks for reminding! +4
Antenka 274 Posting Whiz

Well, if follow your's app logic: the Category must be a part of the Item (belongs to it). So if I were you - I would place the definition of it in Item class. And then import it from that class for using in Tester class.
Hm ... sounds strange. But it's the only thing that I can suggest now :)

kbullard516 commented: Very Helpful +1
Antenka 274 Posting Whiz

Hello, jobi116.
As one of the solutions, I can offer this to you:
there is one function : SHGetFolderPath (shell32), that can help you get the path to 'special' folders, like you are listed. Here you can find much more such folders.
Also there is some class in .Net, that allows you to get path to some of that folders: Environment.SpecialFolder Enumeration.

So all you have to do - catch the 'special' folder and do not add it into your treeview.

P.S. I had some troubles getting the path to the Control Panel, so if you'll get something like that - we'll invent something else ;) Good luck.

P.P.S. If you want to investigate more in using shell, look here:
C# does Shell, Part 1
C# does Shell, Part 2
C# does Shell, Part 3
C# does Shell, Part 4

Antenka 274 Posting Whiz

When you call this:

tail = Counter(tail);

variable tail not gonna change. Your initial value of tail is 0 and if you'll divide it by some number - it will give you 0.

Antenka 274 Posting Whiz

Check for this (msdn):

If visual styles are enabled and EnableHeadersVisualStyles is set to true, all header cells except the TopLeftHeaderCell are painted using the current theme and the ColumnHeadersDefaultCellStyle values are ignored.

I've tried to set the EnableHeadersVisualStyles to false and it's working.

ddanbe commented: Nice. +4
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

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

ddanbe commented: Well noticed! +4
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

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

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
Ezzaral commented: Plenty of info there. +15
Antenka 274 Posting Whiz

Here is part of description of this function, given by java help:
public boolean renameTo(File dest)

It asks a File as parameter, but you give String to it.

Alex Edwards commented: Helpful information =) +5
shubhang commented: Thanks a million for the help. +1
Antenka 274 Posting Whiz

Oh ... it never ends :( Thanks a lot for spending time working with me and my problem. I have tried new variant - same trouble. I found the way to pass through this problem:
I add "\n\n" in the end of request and then when reading from stream I'm checking, if the string ends on "\n\n" i break the cycle.
Here is updated server code (reading part):

while (true)
            {
                int b = is.read();
                if (b == -1)
                    break; 
                request += (char)b;
                if(request.endsWith("\n\n"))
                    break;
            }

It is workibg!
Just interesting, what is wrong? Have any ideas what is that? :)

P.S. about client and server on same machine: this is 3rd home work. Previous 2 also used interacting remote and I tested them on my machine and all works normally.

peter_budo commented: Good luck with your homeworks :) +12