Shananne DuFrame

Ranch Hand
+ Follow
since Nov 13, 2006
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shananne DuFrame

resolved the problem, thanks anyhow.
11 years ago
Now I tried this:



and get this:



Any help in a new direction would be appreciated.
Thanks.
11 years ago
Ok now I tried this:



I get this for results:



Why is only the Aisle 5 not printing correctly?
11 years ago
If I change it to

or this


I get this:
11 years ago
If I change it to this I get the same thing for results


results:
11 years ago
Could someone also take a look at my print by aisle method:

I am getting this for a result:


But should get:


Heres my print method:


I've tried several changes to my loop and am now really getting mind confused as to what I have already tried. I think I am now at a point where I am basically recoding things I have already tried.
11 years ago

because it just currently does not take a parameter?



I didn't have it set up to take any, wasn't quite sure in depth what would all have to be changed to allow this. Also, the instructor, when I mentioned this thought it was a good idea but she also I don't believe was sure on how this could be changed or didn't look into it any further. There were no definitions of this not being allowed for the assignment. The initial instructions are open for uniqueness.

Basically what she does want is 4 classes;
- Grocery - to have gets and sets, constructors.
- Glist - constructors, methods to insert, print list by item(use recursion), print list by aisle(need to sort first)
- InvalidAisleException - to catch invalid aisles.
- Testing class - to create the list, read items from file and add to the list, print by item(as read in from file), print by aisle, then print again by item to verify that it was sorted.

I took it on my self to try to get it to sort the list alpha. It is not a requirement. She explained that the last print was not intended to actually sort it alpha. She claimed that it was only intended to show that the list did resort the list items after running a sort and printing by aisle.

Example of a print out would be:
Enter the input file name: C:\\TestFile4.txt

bread is a duplicated item.
soup is a duplicated item.

The file C:\\TestFile4.txt contains the following items:
milk in aisle 1
bread in aisle 2
eggs in aisle 1
cheese in aisle 1
cream in aisle 1
soup in aisle 5
ketchup in aisle 5
yogurt in aisle 1

The list print by aisle is:
Aisle: 1
milk
eggs
cheese
cream
yogurt
Aisle: 2
bread
Aisle: 5
soup
ketchup

The list printed by item is:
milk in aisle 1
eggs in aisle 1
cheese in aisle 1
cream in aisle 1
yogurt in aisle 1
bread in aisle 2
soup in aisle 5
ketchup in aisle 5

But I was trying to get the last portion to print as such:

The list printed by item is:
bread in aisle 2
cheese in aisle 1
cream in aisle 1
eggs in aisle 1
ketchup in aisle 5
milk in aisle 1
soup in aisle 5
yogurt in aisle 1

And I was merely interested if there was a way that it could have been incorporated to work in such a way. I think it is a good way to learn new things by experimenting.
11 years ago
But a question as you say create another class called compareWidget, Wouldn't the initial start of the merge sort have to change in that it would have to take in a value in it parameter heading as such:

public void mergeSort()<----right here to say if your sending a String item or Int Aisle?? {
first = recMergeSortItem(first);
}//end mergeSort

I thought a real simple way would be to create 2 mergeSorts in my class have one specific for item and the other specific for Aisle and name the methods as such
public void mergeSortItem()
private LinkedListNode divideListItem()
private LinkedListNode mergeListItem()
private LinkedListNode recMergeSortItem()
or
public void mergeSortAisle()
private LinkedListNode divideListAisle()
private LinkedListNode mergeListAisle()
private LinkedListNode recMergeSortAisle()

But this won't work... because the intital call to mergeSort does not use parameters. Oh well was a nice thought.

But I think I see the logic to this compareWidget class. That is then where the mergeSort would then take either the road to item or to aisle? Is this right?
11 years ago
We just learned the very basics of polymorphism. Alot of what was involved was not gone into detail in that the semster is about over.

But I did think of a way that I could resolve this would be to write my own SeqSort method. But that could get real messy and confusing when it comes to swapping part of the nodes.

Needless to say I talked to the instructor today about it, she said that I would have to change my MergeSort back to reading the aisle values instead of the item, just to get the aisles to print in order. She is not so much concerned with the items being in alpha order as the aisle.

This assignment has taught me so much more about linked lists, than the whole semester has. Alot of my learning has come from trial and error.
11 years ago
Hello all,

I have a linked list of Items in aisles. I now want to sort the list by aisle. I have already defined my mergeSort to work specifically for the string item 'item' to put the item in alpha order. What would be my options for now sorting by int aisle value? Would I need to add some sort of selection sort to re-sort it by aisle? Or did I really mess it up by making my mergeSort only usable for the string item?

My Grocery class contains constructors, gets, and sets for items and aisles.

Heres my code for GList


Here's my Test Class


Any ideas in the right direction would be helpful. Thanks.
11 years ago
Hello,
wondering if anyone could help me out. Been trying this one out for awhile. I am trying to get the following to work:

macaroni was duplicated in the list.

This is suppose to be one of my first output lines.
I already have the Exception line working.
I have tried to code the duplicated item several times. Any help in the right direction would be appreciated.

I bolded where I believe my problem is.



This is my results:
Enter the input file name: C:\\TestFile5.txt

InvalidAisleException: Aisle must be 1-5: turkey shows aisle 9

The file C:\\TestFile5.txt contains the following items:
macaroni in aisle 3
chips in aisle 2
macaroni in aisle 3
salsa in aisle 1

The list print by item is:
chips in aisle 2
macaroni in aisle 3
macaroni in aisle 3
salsa in aisle 1

The list printed by aisle is:


----jGRASP: operation complete.
11 years ago
Oh this is the actual output I am getting:

Enter the input file name: c:\\TestFile2.txt

The file c:\\TestFile2.txt contains the following items:
milk in aisle 4
InvalidAisleException: Aisle must be 1-5: bread shows aisle 6
bread in aisle 6
eggs in aisle 1
cheese in aisle 3

Sorry forgot to add that in the first post!!
11 years ago
Hello,
I've been working on an assignment That contains 4 classes.

Grocery - contains date for item and aisle
GList - contains node based list and other info
InvalidAisleException - for invalid aisles
TestList - implements the others

The program reads data in from a file in the format as such:
4
milk
4
bread
6
eggs
1
cheese
3

This is how the output should be after running the program:
InvalidAisleException: Aisle must be 1-5: bread shows aisle 6
The file c:\\TestFile2.txt contains the following items:
milk in aisle 4
eggs in aisle 1
cheese in aisle 3

I think I know where my problem may be but am unsure of what may be causing it. Would appreciate any ideas.

Here's my code where I think the problem may be:
(This is in my TestList class)



If seeing more code would help better figure it out let me know. I've tried moving things around and using the loops differently and it just seems to get worse. If I move the list.printList out of the for loop it only prints one item such as:
milk in aisle 4. Is the way I've coded it not really storing the information in the nodes? When I check list length it does say 4. But why will the list.print() not work outside the loop?

Here is my print method from the GList class:


And this is my toString Method from the Grocery class which obviously what is printing the list, because it displays 'item in aisle *' as coded.


I've tried multiple things with no luck. A lead in the right direction would be helpful.

Thanks,
Shananne
11 years ago
My next problem is how do I create a sort method to sort by item. This would be a string value. I've read up on collections, but don't know if this will work beings I created my own linkedList class. I also tried changing the item to a char but I am unsure how to get this to work with the FileReader. It won't read the item in as a char. Is there anyway to change this line
char item = inFile.next();

or what else would be my other options for sorting strings in a linked list. I found many resolves for arrays but not linked lists.
11 years ago
I got it working in my testing program...
11 years ago