Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C#, Console App (.NET Framework) Please provide the code with Visual Studio Studio screenshot please and thank you. .txt file that has been provided:

In C#, Console App (.NET Framework)

Please provide the code with Visual Studio Studio screenshot please and thank you.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

.txt file that has been provided:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

You will be practicing to read from a file and building a relatively more complex system consisting o the three interconnected types that is illustrated below: All the above type must decorated with the public keyword The SongGenre enum This enum comprise of seven types of songs To code this add a new item to your project and select the class option. Make the necessary changes to the header to reflect the enum type. You should decorate this enum with the Flags attribute, because values may be combined e.g. a song may belong to multiple genres such as Country+Blues. In order to make the flags work as you would expect, you must set each value to an ascending power of 2 e.g. ,1,2,4,8,16 or simply use the binary values as shown in the diagram below. If you examine the binary values for each enum, you will notice that each value has exactly a single value one, therefore as possible value can only come from a unique combination of the base value. e.g. 0 b1_ 010 is a result of combining Rock and Country The Song class This acts like a record for the song. The setter is missing for all the properties Description of the class members Fields There are no fields. Properties: This class comprise of four auto-implemented properties with public getters and setters absent. See the UML class diagram above for more details. Constructor: public Song(string title, string artist, double length, SongGenre genre) - This constructor that takes four arguments and assigns them to the appropriate properties. Method:| public override string ToString() - This public method overrides the ToString() method of the object class. It does not take any argument and returns a string representation of the object. See the output for hints on the return value of this method. The Library class This is the front end of the application. This is a static class therefore all the members also have to be static. Remember class members are accessed using the type instead of object reference. Description of class members Fields: songs - this private field is a list of song object is a class variable. Properties: There are no properties. Constructor: There is no constructor for this class. Methods There are four over-loaded methods. Remember that overloading is a technique used to reduce the complexity of the API exposed by the Song class. public static void DisplaySongs() - This is a public class method that does not take any argument and displays all the songs in the collection. Here a foreach loop is recommended for all of the overloaded DisplaySongs methods. public static void DisplaySongs(double longerThan)-This is a public class method that takes a double argument and displays only songs that are longer than the argument. public static void DisplaySongs(SongGenre genre) - This is a public class method that takes a SongGenre argument and displays only songs that are of this genre. public static void DisplaySongs(string artist)-This is a public class method that takes a string argument and displays only songs by this artist. public static void LoadSongs(string fileName) - This a class method that is public. It takes a single string argument that represents a text file containing a collection of songs. You will read all the data and create songs and add it to the songs collection. Examine the contents of the files for a better understanding of how this should be done. You will have to read four lines to create one Song. Your loop body should Baby have four ReadLine(). The recipe below might clarify things: Justin Bebier 3.35 Pop - Declare four string variable (title, artist, length, genre) to store the results of four reader. ReadLine(). - The first ReadLine( ) is a string representing the title of the song. This can and should used as a check for termination condition. If this is empty then there are no more songs to read i.e. it is the end of the file - The next ReadLine() will get the Artist - The next ReadLine() will be a string that represents the weight. Use the This is a complex method and Convert. ToDouble to get the required type rightfully it should be a part of the Song Class - The next ReadLine() will be a string that represents the genre. Use the Enum.Parse( ) to get the required type - Use the above four variables to create a Song object. - Add the newly created object to the collection. - And finally do one more read for the title to re-enter the loop. P.S. Before running the Library.LoadSongs() you will need to copy the files Week_03_lab09_song.txt, Week_03_lab09_song2.txt, Week_03_lab09_song3.txt and Week_03_lab09_song4.txt to the bin \debug folder. Test Harness Insert the following code statements in the Main( ) method of your Program.cs file: //To test the constructor and the Tostring method Console.Writeline(new Song("Baby", "Justin Bebier", 3.35, SongGenre.Pop)); //This is first time that you are using the bitwise or. It is used to specify a combination of genres Console.Writeline(new Song("The Promise", "Chris Cornell", 4.26, SongGenre.Country I SongGenre. Rock)); Library.LoadSongs("Week_03_lab_09_songs4.txt"); //Class methods are invoke with the class name Library. DisplaySongs(); SongGenre genre = SongGenre. Rock; Library. DisplaySongs (genre); string artist = "Bob Dylan"; Library. DisplaySongs(artist); double length =5.0; Library. DisplaySongs(length); Program output Baby by Justin Bebier (Pop) 3.35min The Promise by Chris Cornell (Rock, Country) 4.26min All songs Baby by Justin Bebier (Pop) 3.35min Fearless by Taylor Swift (Pop) 4.03min Runaway Love by Ludacris (Pop) 4.41min My Heart Will Go On by Celine Dion (Pop) 4.41min Jesus Take The Wheel by Carrie Underwood (Country) 3.31min If Tomorrow Never Comes by Garth Brooks (Country) 3.40min Set Fire To Rain by Adele (Soul) 4.01min Don't You Remember by Adele (Soul) 3.03min Signed Sealed Deliverd I'm Yours by Stevie Wonder (Soul) 2.39min Just Another Night by Mick Jagger (Rock) 5.15min Brown Sugar by Mick Jagger (Rock) 3.50min All I Want Is You by Bono (Metal) 6.30min Beautiful Day by Bono (Metal) 4.08min Like A Rolling Stone by Bob Dylan (Rock) 6.08min Just Like a Woman by Bob Dylan (Rock) 4.51min Hurricane by Bob Dylan (Rock) 8.33min Subterranean Homesick Blues by Bob Dylan (Rock) 2.24min Tangled Up In Blue by Bob Dylan (Rock) 5.40min Love Me by Elvis Presley (Rock) 2.42min In The Getto by Elvis Presley (Rock) 2.31min All Shook Up by Elvis Presley (Rock) 1.54min Rock songs Just Another Night by Mick Jagger (Rock) 5.15min Brown Sugar by Mick Jagger (Rock) 3.50min Like A Rolling Stone by Bob Dylan (Rock) 6.08min Just Like a Woman by Bob Dylan (Rock) 4.51min Hurricane by Bob Dylan (Rock) 8.33min Subterranean Homesick Blues by Bob Dylan (Rock) 2.24min Tangled Up In Blue by Bob Dylan (Rock) 5.40min Love Me by Elvis Presley (Rock) 2.42min In The Getto by Elvis Presley (Rock) 2.31min All Shook Up by Elvis Presley (Rock) 1.54min Songs by Bob Dylan Like A Rolling Stone by Bob Dylan (Rock) 6.08min Just Like a Woman by Bob Dylan (Rock) 4.51min Hurricane by Bob Dylan (Rock) 8.33min Subterranean Homesick Blues by Bob Dylan (Rock) 2.24min Tangled Up In Blue by Bob Dylan (Rock) 5.40min Songs more than 5mins Just Another Night by Mick Jagger (Rock) 5.15min All I Want Is You by Bono (Metal) 6.30min Like A Rolling Stone by Bob Dylan (Rock) 6.08min Hurricane by Bob Dylan (Rock) 8.33min Tangled Up In Blue by Bob Dylan (Rock) 5.40min Press any key to continue... Week_03_lab_09_songs - Notepad File Edit Format View Help Baby Justin Bebier 3.35 Pop Week_03_lab_09_songs2 - Notepad File Edit Format View Help Baby Justin Bebier 3.35 Pop Fearless Taylor Swift 4.03 Popl Week_03_lab_09_songs3 - Notepad File Edit Format View Help Baby Justin Bebier 3.35 Pop Fearless Taylor Swift 4.03 Pop Runaway Love Ludacris 4.41 Pop Baby Justin Bebier 3.35 Pop Fearless Taylor Swift 4.03 Pop Runaway Love Ludacris 4.41 Pop My Heart will Go on Celine Dion 4.41 Pop Jesus Take The Wheel Carrie Underwood 3.31 Country If Tomorrow Never Comes Garth Brooks 3.40 Country Set Pire To Rain Adele 4.01 Soul Don't You Remember Adele 3.03 Sou1 Signed Sealed Deliverd I'm Yours Stevie Wonder 2.39 S11 Just Another Night Mick Jagger 5.15 Rock Brown Sugar Mick Jagger 3.50 Rock All I Want Is You Bono 6.30 Metal Beautiful Day BOno 4.08 Metal Like A Rolling Stone Bob Dylan

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago