• Post Reply Bookmark Topic Watch Topic
  • New Topic

i have try a lot but nothing  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how can I work on it. I have an exercise that tells I have choices 1-9. If is 1 system out somethings. Do some methods and its ok. If its 2 system out somethings .(Now the worst ) if user choose 3 system.out another 3choices and if the user choose the 2 choice he should return to the main list(1-9) .How I do that ? I have done if choice==1 using user input else if choice is 2 and else if choice == 3 .inside the third choice I have another choices and one of it I should use it to turn me back (if the user choose 2).Any ideas? I worked with if.Idk how should I do that.To difficult
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The first thing to do is to understand the problem, draw out on paper what needs to be done. Have you ever done a flow chart or finite state autonoma of any type? You have to read each part and chart out what to do. Do the first part, then add the second part, then so on and so forth until it's all laid out. Then see if you can simplify the diagram or instruction. Once you have a good representation of the problem, then start thinking about code. Too many people think that they can sit down at the keyboard and start coding an answer, when in reality you have to put in the analysis BEFORE you can code anything. This assignment is showing you just how important that is.

In the real world coding only takes a fraction of the time, and most of your time will be spent in problem analysis. That is because no matter how elegant your solution is, if it does not answer the right question, then it's garbage. So take the time and do the analysis of what needs to be done.

Now when ever you see something that says you have to go back to a certain point, that should always make you think of some type of loop. That loop will be an implementation of a flagged exit, some condition becomes true to exit the loop, and your choices will be made inside the loop.

So my best advice is to look at the first part of the problem, and get a firm grasp of what it is asking, then code that. Once that is done, look at the second part of the problem and implement that--it will probably impact what you did in the first part, then do each part that is left in turn.

Good Luck,
Les
BTW: once you get a better grasp of what is happening, ask specifically for help on that part--not here is my assignment, help.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:I don't know how can I work on it. I have an exercise that tells I have choices 1-9. If is 1 system out somethings. Do some methods and its ok. If its 2 system out somethings .(Now the worst ) if user choose 3 system.out another 3choices and if the user choose the 2 choice he should return to the main list(1-9) .How I do that ? I have done if choice==1 using user input else if choice is 2 and else if choice == 3 .inside the third choice I have another choices and one of it I should use it to turn me back (if the user choose 2).Any ideas? I worked with if.Idk how should I do that.To difficult



 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question that you ask--how to return... Is the same advice I gave before, you have to encapsulate that, and up to where you need to return, in a loop that will be a flagged exit. In this case the flag for exit would be everything except the condition that selects the return.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:Your question that you ask--how to return... Is the same advice I gave before, you have to encapsulate that, and up to where you need to return, in a loop that will be a flagged exit. In this case the flag for exit would be everything except the condition that selects the return.
can you give me a simple example because i cant imagine how could it be this?
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to ask questions clearly. You have posted multiple threads and people have generously given you advice. LM's post tells you what you need to know and more important, what you need to do. But you don't appear to have taken any ofl the advice given. If you have difficulty understanding the answers, you should explain what your difficulty is. People here are patient, but you must help them by explaining the problem simply.
You persist in posting incorrectly indented code. Please learn how to indent your code, doing what I call writing backwards. Don't use MS Notepad, but a decent text editor; my favourite for Windows® is NotePad++. Turn on the automatic indentation option, bracket highlighting and syntax colouring. All those things make it easier to read your code. If you cannot understand your code because it is wrongly indented, it is you who are suffering, not we.

Please explain how much you know about object‑oriented programming (=OOP). Where are you learning? Who is teaching you? Are you being well taught? Do you attend all your teaching? Do you listen to what is taught? When you have difficulties, do you ask people locally (or your teacher) for help?

LM's advice to draw a diagram of your program flow is good; have you followed it and what did you get?
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand to do on a paper a plot . A plot what to do and when I do it to go on the netbeans.What I can't understand is what you talking about notepad.Sorry for my posts but I have a lot questions on exercises my intention isn't to disturb no one. I see this website so I came here. Books and internet can't help me so I choose here to express my problems. I didn't understand about flag exit nor what should I do.(yes I have little difficulties to understand English) . My problem is to choice 1,2,3,4,5,6 .After if user choice is 4 to show me a new list with choice 1,2,3,4.If I choose 4 to go back at the previous list . That will work with boolean flag? But how . If I see a code similar I can understand .Believe me I am all day try this but still nothing .I did new class
 
Liutauras Vilda
Marshal
Posts: 4657
320
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry to say that, I have to be honest, but that way you won't solve non of your exercises and doesn't matter how many of them are due to submit.

You can write 100 lines of code, you can create as many classes as you want, but if non of the code is tested by you and you're convinced of it correctness (by actual results/facts), you can assume all is incorrect - and that is almost always true.

Now how to move on with your exercise. CTRL + A; DEL;

Don't worry about your english, it is not that bad, use Google Translator if you can't find some words, but try to describe in simple words, WHAT is the task all about and WHAT the program needs to be doing? Start from the beginning, DON'T go into any technical details which are Java related - most likely there are many different ways to achieve one or another task, that is for later, NOT FOR NOW.

Think about the describing WHAT as about when you are trying to explain to your best friend, how to play one or another board game, card game or any other playing game. You're not going into details how the cards are made, what material is used in domino figures and similar stuff, so you don't need that here too. Just tell, like:
"There is a card game, where 4 people are needed to play it. At the beginning, cards needs to be shufled. All players being given by 7 cards. Player, who has... starts the game..."

Please try once again with explanation, and we will try to do our best with understanding
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:. . . netbeans . . . What I can't understand is what you talking about notepad. . . .
You never said you were using NetBeans. IDEs like NetBeans usually indent code automatically, so I thought you were struggling with a poor‑quality text editor.

Sorry for any confusion.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:I'm sorry to say that, I have to be honest, but that way you won't solve non of your exercises and doesn't matter how many of them are due to submit.

You can write 100 lines of code, you can create as many classes as you want, but if non of the code is tested by you and you're convinced of it correctness (by actual results/facts), you can assume all is incorrect - and that is almost always true.

Now how to move on with your exercise. CTRL + A; DEL;

Don't worry about your english, it is not that bad, use Google Translator if you can't find some words, but try to describe in simple words, WHAT is the task all about and WHAT the program needs to be doing? Start from the beginning, DON'T go into any technical details which are Java related - most likely there are many different ways to achieve one or another task, that is for later, NOT FOR NOW.

Think about the describing WHAT as about when you are trying to explain to your best friend, how to play one or another board game, card game or any other playing game. You're not going into details how the cards are made, what material is used in domino figures and similar stuff, so you don't need that here too. Just tell, like:
"There is a card game, where 4 people are needed to play it. At the beginning, cards needs to be shufled. All players being given by 7 cards. Player, who has... starts the game..."

Please try once again with explanation, and we will try to do our best with understanding
i will try again to describe it I need to create a menu with 7 options.if the choice is 1 i should appear the name.If the options is 2 i should write his name.if is 3 i should appear age .If is 4 i should create an array .if is 5 i should appear the whole array. if is the 6 choice i should see a new menu with 3new options. If the first is of the new menu i should appear a message what ever i want.If the second choice of the new menu i should write numbers and to appear .if the third choice of the new menu to return me back at the first menu.The program will finished only if choice is 7
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you drawn a diagram on paper? Only when you have the diagram will you be able properly to write the code.
If you have a diagram, what does it say against No 1? Forget about 2‑7 for the time being. Only get No 1 working now, and do the others later.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way: have you come across the construct described here in the Java™ Tutorials? That is probably what you want for a menu.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Have you drawn a diagram on paper? Only when you have the diagram will you be able properly to write the code.
If you have a diagram, what does it say against No 1? Forget about 2‑7 for the time being. Only get No 1 working now, and do the others later.
i have done menu1 with ifs .The menu2 i have done it too except the part of return (i mean third options).I will try with switch case now .
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you haven't done menu 2, or if you have it doesn't work. You need to start from scratch, I am afraid, as Liutauras told you yesterday. Please show us the menu for option 1 and whatever method it calls. Nothing else.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:No, you haven't done menu 2, or if you have it doesn't work. You need to start from scratch, I am afraid, as Liutauras told you yesterday. Please show us the menu for option 1 and whatever method it calls. Nothing else.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:No, you haven't done menu 2, or if you have it doesn't work. You need to start from scratch, I am afraid, as Liutauras told you yesterday. Please show us the menu for option 1 and whatever method it calls. Nothing else.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

You don't want code, you want thoughts. Where does the name come from in option 1? Where does Mikael come from? You have simply written something there without knowing why. Only when you know where you are getting the name from can you actually write any code.
 
Paweł Baczyński
Bartender
Posts: 2054
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't like that your methods swallow exceptions and return -1 instead.
What if -1 is a valid number you want to read? The same about the method that returns String.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!