#Reoccuring error. Cash Register system

27 messages · Page 1 of 1 (latest)

wheat vault
#

Hello,

I am a beginner in Java doing a University course. I really enjoy Java and I think it's fun, but I struggle a lot with the assignment given to me.

This is my current code.

I have a problem where if I try to remove an article, it won't go away. If I try to sell an article, it won't go away either and many times there will be an error message due to an occurence. I have tried a lot of methods and I have read the material but I feel like I would need a person to sort of explain what I am doing wrong.

Thank you.

frail pikeBOT
#

This post has been reserved for your question.

Hey @wheat vault! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

thorn cedar
wheat vault
# thorn cedar When you say that when you try to remove an article it won't go away, check whet...

3 scenarios.

  1. I remove an article and it says article removed. This only occurs for article number 1009, weirdly. However, it doesn’t actually go away from the system as desired.

  2. i try to remove / sell any other article number it results saying not found. Article not deleted.

  3. i try to sell any article that is not 1009, I get an error message generated by an exception.

The reason I made them start with 1000 and grow sequentially is because you are able to generate new articles, which seems to be working fine. I have tried making default integer articles ranging from values 1000 to 1009, but it didn’t work either. Like I said, I’m very much a beginner.

thorn cedar
#

You don't make them start with 1000. You're displaying them with that

#

You make them start with 1009

#

I'd say that it's the first thing you need to change: you should display what truly is rather than an altered version of it

wheat vault
#

What do you mean by ”truly is rather than an altered version of it”?

thorn cedar
#

Your articles numbers aren't actually 1000 to some

#

They're 1009 to some

#

So you shouldn't display that they're 1000 to some

wheat vault
#

Okay, I am working on that right now

#

If you check the if condition for the articleRemove method

#

I think the reason the article is not actually disappearing is because it only prints a message and nothing else.

thorn cedar
#

Let's ignore the remove method as long as you've not fixed the display method

wheat vault
#

Lol noted

wheat vault
#

Wait it doesn’t let me send.

thorn cedar
#

I guess you should try code-sharing sites

thorn cedar
#

Looks good. But I don't have time to check anymore

wheat vault
#

Ah, I see. Well, do you have any suggestions what I could do to make it sell articles and reduce quantity?

#

Your feedback was very helpful, I thank you for that.

frail pikeBOT
thorn cedar
#

Now you were talking about "actually removing" articles with the remove method. I imagine rather than setting the values to zero.
I suppose it would be preferable, yes. However it's not going to happen magically. You need to move around stuff until what you have, is that your array doesn't see any trace anymore, of the removed article

wheat vault
#

Interesting way of putting it, will try.