Subhash L. Sriram

+ Follow
since Jan 30, 2005
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 Subhash L. Sriram

I have everything else ready, but am getting ready to submit, or would have posted it. Plus, it is pretty lengthy!
13 years ago

Thank you very much for the hint. I got the printFlight method working, and it does not give me any errors.

Luckily, I got most of it working using my half-hazard way of doing it The last function is something I will have to leave out, because I need to get all the files doc'd up and ready to go....

I will definitely try to get more into cohesion & encapsulation. As a matter of fact, I had to write a paper for this assignment about how those incorporated into my program....oops

I will have to find some time to go over this stuff in more detail definitely!

Thanks again for all your help. I would not even have gotten this far without the great hints!
[ February 20, 2005: Message edited by: Subhash L. Sriram ]
13 years ago

Originally posted by M Beck:
oh, and about the possible suggestion i had -- since, even though it turned out not to be necessary in this case, it might come in handy elsewhere:

basically, you want to look at the last character of the string, check to see if it's a character you might be interested in (like a letter, maybe), and go on looking towards the start of the string if it's not. when you find the first character of the string (counting from the end) that's one of the characters you care about, you ignore everything from that point on to the end, using (for example) a substring() method call. explore the String class and its methods for hints on how to do this sort of thing.

(i'm frankly surprised Java doesn't seem to have a configurable trim() method in String. you'd think people might want to strip off things other than whitespace often enough.)

13 years ago

Thanks to both of you for the reply.

As far as my level, I am not a beginner, I would think a little more than intermediate, but I am also not an expert by any means.

I have done classes before, and was pretty sure I had to do it that way, but got confused and tried to do it this, what seemed to me then, as an "easier" way.

What I have now is, for example:

The way, I have the program written, lets say someone wants to be added as a passenger to Flight 100, I have it like this:

So, the linked list would now be:

Flight 100
John Smith
Flight 101
Flight 102

Then, I also have the remove function working. The problem is when they want to print the passengers for a particular flight.

I thought I could do something like I stated above, adding a printFlight() method to the LinkedList class, starting at the node for the flight they enter, and printing all the data in between that, and the next occurence of "Flight".

To be perfectly honest, I am a senior in Computer Engineering, and last week was midterms. In the mix, I totally forgot about this assignment, and am trying to get as much as I can done by tonight @ midnight!

Also, for engineering majors, they have a class that they claim is to be the equivalent of beginning & intermediate programming rolled into one semester. They cant obviously get all the info from both courses into one, so they skip on alot of stuff.

I took that course 2 yrs ago, and the next course in line was data structures & algorithms. I am having to review everything, and I could definitely use some work in my encapsulation.

If I had more time, I would definitely be trying to get it as structured as possible.

Thanks to both of you for your help. I really appreciate it, and I would like to say this site has been one of the most helpful sites I have visited, where you guys actually try to explain things, instead of just posting code.
13 years ago
Thanks Like I said, it was a stupid mistake that I figured out, but thank you for the explanation, it is easier to understand it now.
13 years ago

I have a linked list called "flights", and between each flight number, there is a passenger list for that flight.

Now, I want to write a function that will print only the passengers for a certain list.

I figured what I can do, is print the elements between the first node, and the next node that starts with "Flight".

My question is, since none of my elements are exactly "Flight", they are all "Flight 100" or "Flight 101", how can I tell it to stop as soon as it finds something that starts with "Flight"?

Is it possible?

Thanks in advance!
13 years ago
Never mind, stupid mistake, got it working....
13 years ago

Thanks for the reply. Now, I am having another problem. There is also a remove() method for my LinkedList class, that finds a certain object, and then deletes it from the list.

It looks like this:

Now, if I have some input, and feed it to the remove method, it gives me another NullPointerException

The find() method is what I have posted earlier. This will not even work explicitly though?

Do you know what I am doing wrong?

Thanks again.
[ February 20, 2005: Message edited by: Subhash L. Sriram ]
13 years ago

You are a genius!

I changed it to this:

And it works fine! Man, that .equals(theItem) and == sure are tricky, huh?

Thanks so much! I have been working on this for hours.......
13 years ago

Thanks for the quick reply!

The following is my find() method:

Should I be changing it to using the equals method?

M Beck,

Could you explain how I would trim the input?

Thanks guys, I really appreciate it
[ February 20, 2005: Message edited by: Subhash L. Sriram ]
13 years ago

I am really confused. I have a linked list, which I have created from scratch, yup this is hw!

The problem I am having is the following:

I have a find method, which will take in an element as an argument, and search the list, and return the node to where the element is located.

Suppose I have the following code:

The above code works fine, and it prints out the value of tmp is "A".

But, if I try the following:

If I input A at the console, it throws back a NullPointerException. I am confused because, if I am inputting the SAME thing at the console, that I am manually putting in, why wont it find it?!?!?!?!

Any help would be greatly appreciated!

13 years ago

Does anyone know of a good reference or tutorial for linked lists? I am having some trouble understanding some of it, and could use the help!

Thanks in advance.
13 years ago

For defining the width in CSS, you would just have:

Here is a great site with a CSS reference, and other programming language information.

As far as your second question, I do not think you ever would have a .xhtml extension, it is more of just a markup inside the .html file. As long as are using XHTML, and it is valid, it will validate.

Hope that helps.
[ February 10, 2005: Message edited by: Subhash L. Sriram ]
Got it. Thanks
13 years ago

First off, sorry if this is a question for the beginner forum....

I am trying to set up a package, and the tree is like this:

├ library
│ ├ array
│ ├ exceptions
│ ├ heap
│ ├ list
│ ├ queue
│ ├ stack
│ ├ tree
│ └ utility
├ program1
├ program2
├ program3
├ program4
├ program5
└ program6

Lets say I have a file "" in my program1 folder, and my Sort class is in the utility program.

Where do I define the package, and how do I import the Sort class into the SortTest file.

I would say it is like this:

But, how do I import it? Do I have to define the package in every file?

Thanks in advance.
13 years ago