Nattakan Lukkanapinit

+ Follow
since Apr 24, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nattakan Lukkanapinit

Sunil Kumar wrote:You have quiet a few problems here
Line 32 : You are iterating on the string array(of length 13) using the length of corresponding element of the array(38). Clearly, when you reach at 13 on str_data[z], it will throw ArrayIndexOutOfBounds
You can fix the above by using str_data.length, but your code piece wouldnt return the desired results. You need to work more on it. I wouldnt want to mention the problems until you give it a try.

thanks for everyone who help me.
ok i fixed all the problem and the program can run without error

this is output of my test program just in main

11 years ago

Jeanne Boyarsky wrote:

Nattakan Lukkanapinit wrote:I have an error at line 38 and 32.

What is the error?

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 13
at test.main(
11 years ago
I have a set of String and would like to convert to 2d array of boolean
I have an error at line 38 and 32.
This is my String
11 years ago
I already finished add and remove but now i stuck at "print all the queue".
The problem is in queue class.
this is my print queue.
It print only the head of the queue, i dont know why.

this is my code

11 years ago
This is stack and i would like to modify it to queue
I tried to put head and tail to it.
Do i have to change when add data in or pull data out ?

This is my new add for queue

Is it ok ?
I can't find the way to pull data out by tail to head
11 years ago

Christophe Verré wrote:"Hong hong",
Did you check your Private Messages ?

11 years ago
I found a little program to test Queue but i can't figure how put this in to class

11 years ago
I get the concept [FILO] of stack but a little confused about Queue [ FIFO].

Anyone have a good example that use add(), remove() [ not collections or generics].

11 years ago
Create a class Agent that contains:

String name - the Agent's name
Client[] my_Clients - an array of Client references. Allocate an array of some fixed size, MAX_CLIENTS, but don't instantiate individual Clients ... we allow this array to point to the caller's Client objects.
int num_Clients - the current number of Clients this Agent has.
MAX_CLIENTS, MIN_NAME_LEN, MAX_NAME_LEN - some static finals to control the values passed into mutators.
Give the Agent class the minimal constructors plus these methods:

AddClient(Client client) - puts client into the Agent's list.
RemoveClient(Client client) - removes client by squeezing him out of the list.
ShowClientsShort() - Displays a list of all this Agent's Clients' names (only names).
ShowClientsLong() - Displays a list of all the Clients, using the Client display method.
double GetIncome() - Returns the dollar amount collectable from all Clients so far this year (based on the tally of the Client member data, percent_cut, and income_this_year.
Create a main program that instantiates a number of Actors and Writers, displays a few of their data to the screen, individually (not all). Next, instantiate one Agent, and place some of the Actors and Writers into the Agent's list. Print out the Agent's Clients' names demonstrating both ShowClients---() methods, and show how much money the Agent is going to get this year.


I tried to add Cli1 in the main just to test but it doesn't work.
the output is "Client@6bdd46f7".
My question is:
How to store "Cli1" in to the array

11 years ago
Why i can't just call like this

11 years ago
This is my code about SUDOKU
I got this error and don't know what it is.

11 years ago
I can't get it work.

This is the step by step to generate new generation
-- PropagateNewGeneration()
3. Convert first_gen (or) this_gen string to string of 0's and 1's
4. Loop through triplets of current string, moving over one char with each loop, for 0 through MAX_LEN-1
5. Determine triplet using shift operator and inner loop: appending each of the three chars into a temp variable
6. Convert each binary triplet to a decimal equivalent
7. Look up tiplet's decimal equivalent 'n' against rules[n] to get new this_gen char for each step in the outer loop
8. Append zero to new this_gen StringBuffer variable
9. Append new char value to with each successive step through outer loop
10. Append zero to this_gen StringBuffer at end of outer loop
11. Convert this_gen back to '*' and ' '
12. Print this_gen to screen
13. Return to step 3 and iterate through all remaining generations as determined by num_generations

This is my code so far :
11 years ago
This is my code

This part that i can't figure it out
I don't know how to implement this
"void PropagateNewGeneration() - this is the workhorse helper function. It will use the two private members this_gen and rule[], and create the next generation from them. This method implements a boundary condition that forces the two extreme positions of each generation to be off (i.e., " "). There are other boundary conditions choices, and this is not the one that will give us unlimited growth, but it has a simplifying effect that keeps the action contained to the width of the seed String. Recall that we took the seed and added a blank before and after that String. This will result in a String that is 2 longer than the seed. Since the rule always contracts the String by two cells (think about it) this means you need to tag-on blanks, again, to both ends of new generation. Add two blanks, apply the rule, add two blanks, apply the rule, etc. This keeps the length of each generation fixed at (the length of the seed) + 2. As I said, this is not the best theoretical boundary condition, but it is an easy one to implement."

11 years ago
Thank you so much.
11 years ago
here is my original code that work with name

but when i change address to price in

It doesn't accept int into it.
11 years ago