❔ Program that gives you a choice of several artists and then their songs
Hey guys! I really need help with this one. I want to write a program for selecting the music artist and his album title. I want a numbered list of three artists and the user selects one of them after that the program displays a list of three titles from which the user selects one. And finaly a message displayed, e.g. You have selected artist A and album title B.
This is my code for now. I really need help to write this :((
Console.WriteLine("Wybierz wykonawcę od numeru 1 do 3 ");
Console.WriteLine("1.The Cure ");
Console.WriteLine("2.Lady Gaga ");
Console.WriteLine("3.Nirvana ");
int wykonawca = int.Parse(Console.ReadLine());
if (wykonawca == 1) ;
{
Console.WriteLine("Wybrałeś wykonawcę The Cure");
Console.WriteLine("Wybierz jeden utwór The Cure");
Console.WriteLine("Lovesong, Disintegration, Wish");
}
Console.WriteLine("Wybierz wykonawcę od numeru 1 do 3 ");
Console.WriteLine("1.The Cure ");
Console.WriteLine("2.Lady Gaga ");
Console.WriteLine("3.Nirvana ");
int wykonawca = int.Parse(Console.ReadLine());
if (wykonawca == 2) ;
// Console.WriteLine(Judas, Pokerface, ""Telephone"");
13 Replies
What is working and what is not working so far? What is your next step?
I don't know how to write it so that it doesn't start with the question "choose an artist" again, but only one such question and then all the possibilities
Do you see why it's doing that according to your code?
The code is doing exactly what you told it to do
Yeah but i dont know how to do it right and much more easier
use object orientation
make 2 classes called Artist and Album
This is a great example of a type of application you want to be "data driven"
TheRanger has the right idea, make classes that represent Artist and Album, then build up your "database" as a list of Artists, where each artist has a list of albums in it.
you then just "pick from a list" twice
could even have that "database" be a json file, or something, if you prefer being able to edit it without changing your code
Hmmmm could you guys send me sample code please?
do you know how to make a class?
No
Then I suggest you learn!
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/classes
Classes
Learn about the class types and how to create them
Seems that's pretty far beyond the scope of OP's assignment
If you want to hardcode all the alternatives in an imperative way, you certainly can - but is that a good idea?
but sure, if all you want is to fix your current code, then the first thing I noticied is that your if statement has a
;
after it, which makes it do nothingWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.