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 dont follow why I would need a Team class and an Individual class

Ok, let's start from the understanding OOP. The Game class is clearly specified in your assignment, so I'll pass it. What is a base class and what are the child ones? The base class is intended to describe the common entity. The common characteristics and behaviour of some group of the other, more-specific entities. By now, it sounds confusing, but let's see and example: suppose, we have to describe a few birds (let's take a sparrow and a penguin). We have some common characteristics for all the birds (like size and color) and some differences (some birds can't fly).

If we'd start to describe the birds in java, we'd create 2 classes:

class Sparrow{
    String color = "brown";
    String size = "small";

    public void fly(){
        //some code to make a sparrow flying
    }
}

class Penguin{
    String color = "black";
    String size = "medium";
}

All the classes contains described characteristics, but there's something wrong ... what if we have to describe a 20 birds ... should we copy-paste all that to all the classes? And here comes OOP (one of the many ways to apply it). We can extract the default characteristics into a base class Bird and just say something like: "The sparrow has all the Bird stuff, but with it's own detailes".
So, we move the common staff into a base Bird class:

class Bird
{
    public …
Antenka 274 Posting Whiz

Ok, seems like I did the most work for you :) Try to complete my code, according to your assignment and show us what you come up with. Ask, if anything in my explanation isn't clear for you, or if there any troubles with completing the task.

Antenka 274 Posting Whiz

Well, I'm not too good in knowing JMF, but in pieces, maybe we could gather all the info from different solutions provided in both threads into 1 working prog.
As a starting point, I'd like to provide one more link: Code Samples and Apps. The interesting sample is SimplePlayerApplet.java.

It's description:

A simple applet that can be used to run a JMF player for a particular media file, this applet embeds the visual component and control panel component in the browser page.

So, you can start by finding out how it works and how the basic things done there.
Then - you can find, how to use streaming with this Player. And one-by-one add needed functionality to it.

If you'd have any questions about the sample or any other features, that you're going to add, feel free to post here the problematic code or more specific question and people with pleasure will help you.

Just show some effort, because by now your question looks like asking for a ready-made solution.

Antenka 274 Posting Whiz

Let's start from the beggining ...
The main points in your assignment are:

  1. "inherits from Game". From those, we have that the base class would be Game.
  2. "game is a team or individual game". Look closer at the wording. Game is Team Game. And game is Individual game. From which, we can assume, that there're our child classes. "Is" is describing one of the class-to-class relationships. You can easily read this as "Team Game is also a Game" and "Individual game is also a Game".
  3. "game can end in a tie". From this we have a characteristic, that have a Game class, which we extracted at the first. step.

I don't know, where you took the "toString()" thing and the others ... if there're some other details on your project, please post them. By now, let's tie to the conditions that we have:

From step one we have:

public class Game
{

}

From the second step, we're adding two child classes, which have an "is"-relationship with our base class:

public class TeamGame extends Game
{

}

public class IndividualGame extends Game
{

}

And at the 3rd step, we determine, that we have a common characteristic, that would reside at the "Game level".

public class Game
{
    boolean canTie;
}

That's pretty much all, that we know from your assignment, but I hope, you got the idea ;)

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

You can take a look at the progs, that you usually use: different viewers, chat clients, Music/Video players, file managers, hardware utilities etc. etc. .. and make your own. With the functionality, that it's missing (well, actually about any prog you can say "It's a good one, but if it has <something>, it would be much better!" :D) .. so you have a chance to add this something and enjoy a perfect prog ;)

Antenka 274 Posting Whiz

*sigh* .. owkies .. btw, have you tried solution from my last post?

Antenka 274 Posting Whiz

Well .. I have one more link for you: Walkthrough: Saving Data from Related Data Tables (Hierarchical Update).
And there, find the section, that says:

In addition to committing changes on a related child table before saving data to a database, you might also have to commit newly created parent records before adding new child records to a dataset. In other words, you might have to add the new parent record (Customer) to the dataset before foreign key constraints enable new child records (Orders) to be added to the dataset. To accomplish this, you can use the child BindingSource.AddingNew event.

.
If it wont work - then I'm waiting for the test app :)

Antenka 274 Posting Whiz

I guess, one of the easiest things is Bubble Sort. It shall do this trick ;)

Antenka 274 Posting Whiz

Can you make a test project and attach it to post so I could play a bit with it? (by the way, that's how I found the answer on one of my questions .. so this won't make any harm .. I guess :D)

Antenka 274 Posting Whiz

Oh .. I guess, I found it .. take a look at this: How to: Save Dataset Changes to a Database. There's a section Updating Two Related Tables in a Dataset that might be highly interesting for you ;)

Antenka 274 Posting Whiz

already solve the problem

Please, post your code, so the other people who would face the same problem - will easily find the solution.

can you help about this

Take a look at Determining the Active MDI Child

Antenka 274 Posting Whiz

That's really weird when your prog founds a 3d char in a 2-char string ;)

Antenka 274 Posting Whiz

Please, post the full code, that you have at the moment (where you create MdiChild and when you work with it's text: get and output).

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

If you'll look closer to these methods, you'll find that some of them (not sure .. maybe all of them) have a overload with an option to compare strings ignoring case. E.g.:String.Compare Method (String, String, Boolean)

Antenka 274 Posting Whiz

No-no .. I tried to lead you in other way.
In your program, you have both: reference to an object and reference to an assigned method. That's too many to call 1 single method.
If need to call the method, not depending on object, you can use this:
Delegates in C#
If you need to call method on a specific object (with thread considerations), you can take a look at this: Dispatcher Class

Antenka 274 Posting Whiz

Ok then .. going back to my previous question:
Why then you're creating a writerDelegateInstance delegate to store the reference to this method? .. if you don't really use it.

Antenka 274 Posting Whiz

To compare strings you should better use this: Comparing Strings

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

Hello, Enrique.
I'm just wondering, why are you trying to access the method through form1Instance instance?

Why then you're creating a writerDelegateInstance delegate to store the reference to this method?

Also, to escape circular references, you can specify the full qualified name of a class (including it's namespace): SameSpace.Form1 .

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

Sure, you can.
You get the text of a label:

label1.Text

in the same way you can get the text of your textbox.

Antenka 274 Posting Whiz

You're comparing your number with largest to obtain the largest one ...
What are the positive numbers - the numbers, which are bigger than 0 ..

Antenka 274 Posting Whiz

Uhm .. owkey .. let's try to compose it. For example, you found a match in the element AddressBook[0,1], so you need to write the exact "AddressBook[0,1]".

Let's divide this string into 2 parts:
1. Static. Means that it would remain the same for each output: "AddressBook[", "," and "]".
2. Dynamic. Means that you have to obtain it's value each time: "i" and "j"

To concatenate your strings you use "+" sign.
The most interesting part is that you already have such combined output in your code, e.g. here:

Console.WriteLine("First Name: " + AddressBook[0, 0] + ". Last Name: " + AddressBook[0, 1] + ".");

Now, try to compose ... ;)

Antenka 274 Posting Whiz

What stops you from using your AddressBook , i , j variables to print the results? ;)

Antenka 274 Posting Whiz

Hello, jboy1803.
Here we go ..

this.laptop_InformationTableAdapter.Fill(this.laptopsDataSet.Laptop_Information);

Here, you make your adapter to obtain the data from your DataBase and put it in the specified table. You can treat adapter as a communication channel between your DataBase and the DataSet/DataTable in your App.

List<string> manufactures = new List<string>();
for (int i = 0; i < laptopsDataSet.Laptop_Information.Count; i++)
{
manufactures.Add(laptopsDataSet.Laptop_Information.ElementAt(i).Manufacturer);
}

Here you iterate through the result table and extract ALL manufacturers into a Collection.

int index = 0;
foreach (string s in manufactures)
{

if (s.Equals("Sony"))
{
label1.Text = laptopsDataSet.Laptop_Information.ElementAt(index).Model;
break;
}
else
index++;
}

Here you iterate through the result collection and search for a Sony manufacturer. If you found one - put it in the Label.

That's pretty much all :)

Antenka 274 Posting Whiz

:) Take a look at this discussion: How to search a string in String array. There're a few ways on how to achieve that (including collections).

Antenka 274 Posting Whiz

Is it a requirement to use an array (rather than a collection)?

Antenka 274 Posting Whiz

Hello, Justin.
I don't know the ColdFusion, so I'll try to guess what you want :)
The closest solution I came up with is:

<% string[] list = { "red", "blue", "yellow", "green" };
   for (int i = 0; i < list.Length; i++) {
       Response.Write(list[i] + "<br />");
}%>
Antenka 274 Posting Whiz

Hello, zachattack05.
Can you provide a code, which is used to save your data? So I can analyze what's happening wrong there.
I don't see the advantages from breaking all this into 2 steps (you still need to update both tables). Maybe I misunderstood something :-/

Antenka 274 Posting Whiz

If your function can be shared between few forms, why don't take it off the specific form and put it in a separate class?
It even can be a static method, accessible from outside. So you just call it in your forms.

Antenka 274 Posting Whiz

Hmmm ..
How about this:

studentchildform = new student();
studentchildform.MdiParent = this;
studentchildform.Show();
Antenka 274 Posting Whiz

Hello, ZER09.
Public property is enough to get this working. I've tried, and it displayed all I wanted. Can't say why yours is acting wrong. Can you provide a code, where you add a child form to a parent MDI container?

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

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

Antenka 274 Posting Whiz

Hi, haanjae.
Maybe you could post the solution you came out with, so the people, who would face same problem also be able to obtain the solution ;)

Antenka 274 Posting Whiz

At first, Dns.GetHostAddresses means a few adresses (see MSDN). It returns an array.

The second is .. as MSDN says:

Dns.GetHostName Method
Gets the host name of the local computer.

Means that it will get the address of the machine, on which, this part of code was executed.
If you'd have a client part of your application on a different PC and run this code in the clients part - then it would return the address of that remote PC. But if you would run this code on a server, you'd always get the same result - name of a current machine.

Antenka 274 Posting Whiz

Yes, this is what was on your screenshot. I was asking, what if you have 2 different pairs of duplicates (see my example)?

Anyways, I gave you a link .. have you checked it?

Antenka 274 Posting Whiz

Heh, ok. Waiting for your results, cause I'm also not able to test these solutions right now :(

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

Hi, GonzR.
Here's a few points that may be helpful:
1. Char.IsLetter Method (Char).
2. Char.IsDigit Method (Char)
3. In C#, strings are char arrays, so there's no need to convert them. You can just iterate through string using any loop.
4. Also, there's an option to check your string, using regular expressions. Maybe it's too early, but still, here's a link: C# newbie: verifying that a string contains only letters.

Also, I would like to ask .. what magic are you doing with converting your numbers? :D Considering that the number literals in C# are treated as Int32 (or int) ...

Antenka 274 Posting Whiz

Hello, lianpiau.
What if you find 2 duplicates (with a different content) for single column? Say,
Column1 Column2
r1 text text1
r2 text text2
r3 text3 text4
r4 text3 text5

What rows should be highlighted?

Also, here's a post with a similar question: How to check duplicate data in datagridview (Well, there still remains a little bit of work to make it act as you want :))

Antenka 274 Posting Whiz

Agreed, my bad. Thanks for correcting :)

Antenka 274 Posting Whiz

Or something like this:

IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
foreach (IPAddress address in addresses) {
    //for IPv4 .. if needed :)
    if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
        Console.WriteLine(address);
    }
}
Antenka 274 Posting Whiz

Hello,
your code seems to be ok. But, one thing that I suspect .. what is the value of "ctrl.Controls.Count" when you get the

error that @chkText either has already been set

? Try to debug .. what conditions are, when your prog is trying to add this parameter more than once.

Antenka 274 Posting Whiz

This thread never gonna die! :D

Antenka 274 Posting Whiz