lundi 6 janvier 2020

(Java) Getting a random line from a text file and separating variables [closed]

i am trying to make a game wherein the user is given the name of the artist and the first three letters of a song name. My text file (Z:\Documents\Songs.txt) is set up in the format: Artist,SongName, for example "Queen,Bohemian Rhapsody".

I need to my program to choose a random line from a text file so that it can output the variable 'Artist' and SongName.substring(0,3) so that the user can guess the name of the song. How do you do this? I do not know how to get random lines from a text file, nor how to manipulate the contents of said lines. I also need this code to be as simple and compact, with as few new methods as possible. Any help is greatly appreciated, thanks.




Aucun commentaire:

Enregistrer un commentaire