C
C#9mo ago
Raf Camora

✅ If i choose an option then i get nothing in the output

I have made an ticketsystem and you can use arrows to select an option but only the option exit works the first option and second option doesn´t work how can i fix this?
62 Replies
Raf Camora
Raf CamoraOP9mo ago
Accord
Accord9mo ago
Closed!
leowest
leowest9mo ago
case 1:
controller.ShowTicketInfo();
Console.WriteLine("press any key to continue...");
Console.ReadKey();
break;
case 2:
controller.ShowTotalAmount();
Console.WriteLine("press any key to continue...");
Console.ReadKey();
break;
case 1:
controller.ShowTicketInfo();
Console.WriteLine("press any key to continue...");
Console.ReadKey();
break;
case 2:
controller.ShowTotalAmount();
Console.WriteLine("press any key to continue...");
Console.ReadKey();
break;
what happens it when u chose either option it reaches Console.Clear(); so fast u dont see them showing up by adding a console.readkey or some other mean u allow time to read it u might want to rethink your logic so it stays on screen
Raf Camora
Raf CamoraOP9mo ago
okay The code works now but if i run the code and press enter i get the ticketinformation while if i press p for example then i have the menu to choose which option i want https://paste.pythondiscord.com/A3CA Code https://paste.pythondiscord.com/Q4YQ Json
leowest
leowest9mo ago
moment I will check your changes
Raf Camora
Raf CamoraOP9mo ago
Okay thank you
leowest
leowest9mo ago
yeah that works too its similar to what I did didn't need to change the switch but yeah
Raf Camora
Raf CamoraOP9mo ago
Its weird if i press enter i get the ticketinformation while i have not chose for that while when i press p except p you can choose every pressbutton but only enter wont work to get in the menu i get the menu and then i can choose
leowest
leowest9mo ago
let me see because your default option is 1 so if u hit enter it enters the if (keyInfo.Key == ConsoleKey.Enter) u should probably reset the selectedoption to 3 and set it default to 3 or some other invalid option so ti goes back to the menu int selectedOption = 1; so I hit enter it enters the if and prints the option 1
Raf Camora
Raf CamoraOP9mo ago
so change it to 3
leowest
leowest9mo ago
I assume if u choose 2 and then hit enter it will show 2
Raf Camora
Raf CamoraOP9mo ago
oh
leowest
leowest9mo ago
either change it to 3 or set selectoption to say -1 or 4
Raf Camora
Raf CamoraOP9mo ago
okay
leowest
leowest9mo ago
and after it shows the option set it back to 4 for example
Raf Camora
Raf CamoraOP9mo ago
which line it is acutally me and my friend who are working on this system
leowest
leowest9mo ago
inside your if !=3 and where u declare/initialize selectedOption
Raf Camora
Raf CamoraOP9mo ago
line 83
leowest
leowest9mo ago
anyway it will most likely mess up with your up/down arrow if u add an extra option so u would have to handle that or just add an extra option before exit saying go back to menu and use that one as default
Raf Camora
Raf CamoraOP9mo ago
it doesnt work if i change it to 4 if i change it the menu is messing up
leowest
leowest9mo ago
well u need to change your logic to account for the option 4 so I would move exit to 4 go to menu would be 3 then u have to increase your uparrow limit ur for count
Raf Camora
Raf CamoraOP9mo ago
i need to press my up arrow to use an option of the menu while down arrow is needed
leowest
leowest9mo ago
yes but right now its limited to 3 if u now have a 4th option then it needs to be a different number to limit dont u think
Raf Camora
Raf CamoraOP9mo ago
so would be if != 4 good if i set line 83 to 4
leowest
leowest9mo ago
that is not the only think u have to change every other line that limits the options needs to be changed
Raf Camora
Raf CamoraOP9mo ago
its so hard
leowest
leowest9mo ago
why? u have 4 options before u had 3 all u need to do is change 3 to 4 but its not only on the if there are other places
Raf Camora
Raf CamoraOP9mo ago
but do i need to change the if also to 4 the line 83
leowest
leowest9mo ago
if u moved your exit to option 4 then yes
Raf Camora
Raf CamoraOP9mo ago
but i have 3 options in menu
leowest
leowest9mo ago
didnt I just say add an option before exit that says go back to menu?!?!
Raf Camora
Raf CamoraOP9mo ago
but i only need 3 options they said not more
leowest
leowest9mo ago
then you have to change your logic
Raf Camora
Raf CamoraOP9mo ago
it wont work anymore since 4 is needed
leowest
leowest9mo ago
u still have your old code there
Raf Camora
Raf CamoraOP9mo ago
its weird that only enters gives the information but pressing something else not
leowest
leowest9mo ago
because you wrote it so that when enter is pressed it checks the options to print
Raf Camora
Raf CamoraOP9mo ago
do you have an idea what i can change that will work good
leowest
leowest9mo ago
is that navigation with up and down needed? what is the actual requiriment
Raf Camora
Raf CamoraOP9mo ago
yes it needs to be an menu with 3 options and there need to be an arrow to choose an option
leowest
leowest9mo ago
because if I dont know the requirement then I wont be able to help and will most likely suggest things u can't use
Raf Camora
Raf CamoraOP9mo ago
this is it
leowest
leowest9mo ago
ok so my suggestion is
leowest
leowest9mo ago
remove this
No description
leowest
leowest9mo ago
and move this
No description
leowest
leowest9mo ago
before the ConsoleKeyInfo keyInfo = Console.ReadKey(true); then it will enter the menu options with the arrow on option 1 so if they hit enter it makes sense it show the ticket information
leowest
leowest9mo ago
it will start your app like this
No description
leowest
leowest9mo ago
do u understand what I am saying? was that too confusing?
Raf Camora
Raf CamoraOP9mo ago
Wait can you show me in discord paste I am a beginner in C# thats why it is confusing
leowest
leowest9mo ago
u remove the lines that are inside the red square on the first image u select all the lines that are in red on the second image copy it, then deleted it then you paste it again before the line where it says ConsoleKeyInfo keyInfo = Console.ReadKey(true);
Raf Camora
Raf CamoraOP9mo ago
Okay
leowest
leowest9mo ago
u should be able to do that much your self
Raf Camora
Raf CamoraOP9mo ago
It is confusing but now I understand Now the selectoption can still be 1 right Or should it still be 4
leowest
leowest9mo ago
yes u dont have to change anythign else
Raf Camora
Raf CamoraOP9mo ago
Okay clear
leowest
leowest9mo ago
can u $paste your file
MODiX
MODiX9mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
leowest
leowest9mo ago
to the site above so I cna see if u changed it right
Raf Camora
Raf CamoraOP9mo ago
Wait I can do it tomorrow im now not be able to have access on my laptop I am on my phone
leowest
leowest9mo ago
sure
Raf Camora
Raf CamoraOP9mo ago
Thanks man
Want results from more Discord servers?
Add your server