Hannah Sigmon

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

Recent posts by Hannah Sigmon

I'm beginning to learn how to make applets and I'm having a lot of trouble. The components here display fine, but when the window is resized, the width of the components doesn't resize, and neither does the height of the JTextArea, although the height of the JList does. Additionally, when I make the window really small, the JTextArea covers up the JComboBox, although the JList doesn't do that to the JTextField or the JButton. Any advice? I'm a complete novice at this.

10 years ago
Well, I fixed it to where it is no longer giving me the NullException, but now instead of deleting only the items that have a price variable greater than bankAccount, it is just deleting everything, or so it seems. I have a method called writeOutput that just prints all the items in the linked list, and when I call it outside this method here, it works fine. But either it is messed up inside this method or the deleteCurrentNode method doesn't work, because the code doesn't output any items. This is what I have now:



And this is what I get back (these items and their attributes have already been input by other methods):


Item name: hat
Item quantity: 4
Item price: $17.15
Item priority: 1

Item name: shoes
Item quantity: 2 pairs
Item price: $18.8
Item priority: 2

Item name: boots
Item quantity: 3 pairs
Item price: $24.58
Item priority: 3

How much money do you have to spend (in dollars)?
40

You bought these items:

You started with this much money: $40.0

You have this much money left over: $4.05

when instead it should say:

You bought these items:

Item name: hat
Item quantity: 4
Item price: $17.15
Item priority: 1

Item name: shoes
Item quantity: 2 pairs
Item price: $18.8
Item priority: 2

You started with this much money: $40.0

You have this much money left over: $4.05

And the boots should have been deleted because they were too expensive.
10 years ago
We are supposed to be creating our own Linked List class and they are confusing me to death. The linked list is supposed to contain objects of the class Item, which is a private inner class within the Linked List class. Each object of Item has a double variable called price, and I'm trying to the value of price of each object in the Linked List, and if that value is greater than another double (called bankAccount), then I want that object to be deleted. For what I have now, everything seems to run fine except the delete method. When an object has to be deleted, this is the message I get: Exception in thread "main" java.lang.NullPointerException
at StringLinkedList$Item.access$0(StringLinkedList.java:22)
at StringLinkedList.deleteCurrentNode(StringLinkedList.java:268)
at StringLinkedList.goShopping(StringLinkedList.java:286)
at StringLinkedListDemo.main(StringLinkedListDemo.java:52)

I really have no idea how to fix this. Any suggestions?

10 years ago