Help coderanch get a
new server
by contributing to the fundraiser

kamal lamgade

Greenhorn
+ Follow
since Sep 11, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kamal lamgade

Hi! If i have a spider algorithm which implement a crawl method that crawl the web from a given seed URL and list all the URL that it visit and a GUI which allows a user to specify seed URL and a keyword to be searched, then how can i use that algorithm to explore the web searching for pages whose meta keywords contain the specified key word that was given in the GUI and display them on screen? Went through several materials but got stuck to start on how can i like the output of a method to display on the ListModel, pic of my GUI is attached hereby , some ideas please. Cheers!!


8 years ago
Hi!! I am trying to analyze the complexity of merge procedure for merge sort to combine k sorted arrays with n elements into a single sorted array of kn elements My understanding so far on this:
1. Step 1: Firstly creating an output array of size n*k then create a min heap of size k and insert first element in all the arrays into a heap.
2. Step 2:Then get minimum element from heap(which always at root) and store it in an output array and replace heap root with next element from the array from which the element is extracted.If doesn't have any more elements in array then replace with infinite.
2. Step 3: Repeat the 2nd step n*k times.
This approach of merging sorted arrays takes O(nk*Logk) time using Min Heap.
Please suggest with some more ideas and detailed explanation. Thanks in advance!!
8 years ago
Hi!!
The one below is the exercise I'm trying :
"Create a file BinarySearchTree.java which implements a simple binary search tree. Each node in the tree should store two pieces of information: a String variable called name, and a int variable called mark.The nodes in the tree are sorted by name in alphabetical (dictionary) order. " This is how i am trying . Is it a right way?

Some ideas would be really appreciable. Cheers
9 years ago
Hi! I am beginner in java and looking for some help and ideas in developing basic solitaire game. To start-with , I am trying to implement just one class and it's methods at the moment and below is attached code and snapshot of what I tried. please suggest where and what sort of changes I need to make ? Thanks in advance!!

Class : Card

Fields:
cardIndex: The card's index, from 1 to 52.

Methods:
getSuit: Returns the card's suit.
getValue: Returns the card's value (such as 10, king, etc).
colour: The colour of the card is `red' if this card is a heart or diamond, and `black' otherwise.

toString: Returns a string representation of this card, including its suit and rank. Example: Ace of clubs would be ClubA, ten of diamonds would be Diamond10, and queen of spades would be SpadeQ.

paintThis(Graphics g) Draws the card. In the simple GUI, this should draw a Rectangle, with the string representation of the card written in the colour corre-sponding to the colour of the card (either black or red)

9 years ago
So far I have able to draw one square from origin as attached in pic below. However I tried to make a grid for checker but couldn't I know it's using for loop and array but no idea where to start from?

9 years ago
Hi!

I am trying to make a flowchart for a c++ program. Could anyone tell me is it fine to protype 3 functions in a same predefined process shape ? or must be one in one shape?
9 years ago

Campbell Ritchie wrote:If you have done that in the constructor then the List is regarded as a standard field in the object and the overridden paintComponent method will draw the square straight off. In which case, why do you want a Listener at all?



Thanks a lot . I am finally done with that now it's drawing.
I stored the points in Point1 and Point2 then inside drawLine i did (drawLine ((int)Point1.x , (int) Point1.y , (int) Point2.x , .. so on
9 years ago

Campbell Ritchie wrote: . . . don't quote everything and don't write code tasgs by hand. . . .



Thanks I will try that in next quote .
Did you mean calling the (Point)ois.readObject(); method ?? inside actionPerformed ?
I am not sure which one you mean because i have done those inside a constructor not inside a method. Is it better you do that inside a method ?
9 years ago
// In my drawingDisplayer where I have created all my controls , inside the constructor I have this for draw JButton with adding ActionListener

// And, Outside the constructor I implemented Listenr to ButtonHandler class. Now, As I have added the points to list in constructor but not inside a seprate
//method , how can i call the action inside the actionPerformed method to draw that square when i click the button?? please help.

P.S : And, What's my mistake in code tags ? Isn't it correct?
9 years ago
. Yes , Progressing . Thanks a lot.

Yes , I know about Listener . I used actionLister and inside actionPerformed method I tried :
if (source == drawButton)
{
repaint();
}
But, it didn't work. I reckon it's because as per the question I have got a drawing class where the paintComponent draws square using Points from file and I have another DrawingDisplayer class with GUI where i have draw button. So , I am trying to connect this two. I used DrawingDisplayer extends Drawing and also created an object of that class then did the code above (repaint()) but didn't work.
Could you please help how can I connect these those class and get the drawing to display on panel when i click draw button?
9 years ago

Campbell Ritchie wrote:

kamal lamgade wrote: . . .
getting end points of connected line segments in the drawing where null point indicates a break in the lines.

Have you found classes like GeneralPath? I think that may be legacy code now, but there is something else similar


it's a data file ("square.drw") .. I am not being able to get those points that's where im struggling .

And what happens when you print out the points in the loop


yes, you are right they are java.awt.Point .
That my mistake i should remove the +1 but couldn't find the edit option now .

It has been disabled


As far as i know , It's possible using arrayList <Point> but I was not too sure this way .
Could you give some idea in which way would you think it easy to understand . Please help.

You still haven't provided all the information. What happens when you change line 18 to this?
System.out.println(oos.readObject());
What happens if you create a List?
List<Point> points = new ArrayList<>();
Then you add each Point to the List?
points.add((Point)oos.readObject());



Thanks. I tried the same way and finally at least now its drawing a shape from those point objects in file "square.drw" .
This is how i tried:

// Inside constructor (which has File file as a parameter ). then I read the file "square .drw" wrapping it with ObjectOutputStream , then created a ArrayList of Point object ,added all those Points to the list .


Now, What I am trying is to set an ActionListener to the draw JButton when clicked, want it to perform the same action to draw a square .. Additionally, after that trying to use timer class and it's method to draw those lines one at a time so when you click the draw button , you can see drawing one line at a time but ending up with a square. SORRY I TRIED TO WRAP WITH CODE TAGS BUT I DON'T KNOW WHERE I MADE MISTAKE.
9 years ago

Campbell Ritchie wrote:I deleted the duplicate post.

And what are you getting out of the file? What format is the file? Are you actually getting points? Can you print those points to screen? What sort of point are they? Are they java.awt.Points? Why have you written + 1 in the loop (line 44)? Doesn't that produce Exceptions? Why are you not closing the stream in a finally? You appear to be reading something from the file and not using it (line 18).
Why put those points into an array? Why not a List<Point>?




getting end points of connected line segments in the drawing where null point indicates a break in the lines.
it's a data file ("square.drw") .. I am not being able to get those points that's where im struggling .
yes, you are right they are java.awt.Point .
That my mistake i should remove the +1 but couldn't find the edit option now .
As far as i know , It's possible using arrayList <Point> but I was not too sure this way .
Could you give some idea in which way would you think it easy to understand . Please help.
9 years ago
Hi!
My actual question is : I am trying to read Point objects from the data file square.drw which are the endpoints of connected line segments in the drawing (square), where null point indicates a break in the lines. Then, overriding paintComponent method of JPanel and trying to draw parts of the drawing . I am not too sure about the way i tried to insert points in an array.


9 years ago