Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CMPSC 221

OO Programming with Web-Based Applications

Spring 2022

Instructions: Please create a Java application to solve the following problem. Documentation                  requirements follow the problem specification. Upload digital copies ofyour program source code, text file, and two or more sample runs to Canvas by the deadline. For the source code and text file, you        may: 1) compress (i.e., zip) your entire project folder (NetBeans, Eclipse, etc.) and upload that to           Canvas OR 2) place your Java source code file(s) and text file in a folder, compress the folder, and         upload that to Canvas. For the sample runs, copy and paste the output for two complete runs ofthe         program into MS Word, save the Word document, and upload that to Canvas. You may submit your       program source code, text file, and sample runs in a single compressed archive, ifyou like. Important Notes: Please be sure to upload your Project 4 files to Canvas by the deadline. If you miss the deadline, you WILL automatically receive a grade of 0 (zero). Also, e-mail submissions are NOT allowed.

1. Problem: Create a Java application that enables a user to create a playlist from an online music library. To clarify the problem, I have divided it into 3 parts.

Part 1: Create Music Library. The program begins by creating an online music library from a list of music selections stored in a text file.

Part 2: Create/Delete/Modify Playlist. After creating the music library, the program welcomes the     user, then provides him/her with a menu of options for creating or deleting a playlist, adding              selections to or removing selections from the playlist, or quitting the application. Creating a playlist   entails creating an empty playlist. Adding a selection to the playlist entails searching the music          library first by artist then by title to locate the selection to add. Removing a selection from the            playlist entails displaying the playlist selections, numbered, then prompting the user to enter the         number of the selection to remove. Deleting a playlist entails simply deleting it (i.e., you do not have to empty it first). The playlist must be displayed after each addition or removal. The program             continues to loop until the user decides to quit. Additional notes for Part 2:

- Attempting to add a selection to a non-existent playlist is an error. A user who tries to do so must be informed that s/he must first create a playlist.

- Attempting to remove a selection from an empty or non-existent playlist is an error. A user who tries to do so must be informed of his/her error.

- Attempting to delete a non-existent playlist is an error. A user who tries to do so must be informed of his/her error.

- Attempting to create a playlist when one already exists is an error. A user who tries to do so must be informed of his/her error.

- All user input must be validated. Specifically: 1) Y/N responses must be case-insensitive and validated (i.e., only responses ofy, Y, n, or N are allowed); 2) Numeric responses must be        validated for range and type.

Part 3: Thank User. Finally, the program thanks the user for using the online music library. As usual, yourprogram output should strongly resemble the sample runs at the end of this document.


Implementation Requirements and Guidelines:

All music selections must be stored in and read from a text file. An example of recommended formatting for the text file appears at the end ofthis document.

Java code that accesses the text file must be enclosed in a try-catchblock. Minimally, your       program must handle the FileNotFoundException. (Important Note: Hard coding the name of your input file into your source code is acceptable; hard coding the path to your input file is not.)

You must use a minimum of two classes to implement this program: a “driver” containing main and a MusicSelection class.

The music library and the playlist must each be implemented as an ArrayList of MusicSelection objects.

A MusicSelection object must have a minimum of5 attributes: genre, artist, title, album, and release date.

Required methods for the MusicSelection class include:

o A five-argument constructor that initializes the five instance variables (specified above).

o set and get methods for each of the five instance variables.

o A toString method to generate nicely formatted output.

The music library must contain at least 20 music selections representing a variety ofgenres and artists.


Documentation Requirements:

1)  Each program source code file (i.e., Java class) must have a header at the beginning ofthe class containing the following:

Name of author, PSU e-mail address of author, name of course, assignment number and due        date, name of file, purpose of class, compiler/IDE, operating system, and any external references used (e.g., Website)

Example:


/*

Author:

E-mail:

Course:    Assignment: Due date:   File:      Purpose:

Compiler/IDE: Operating    system:      Reference(s):


*/


Wanda Kunkle

[email protected]

CMPSC 221

Programming Assignment 4

3/28/2022

MusicLibrary.java

Java application that enables a user to create a playlist from an online music library

Java 17.0.1/Apache NetBeans 12.6

MS Windows 10 Home

Java 17 API - Oracle Documentation                     (https://docs.oracle.com/en/java/javase/17/docs/api/);  (Include ALL additional references (Web page, etc.) here.)


2)  The purpose of each method in the source code file(s) must be documented as shown in the example below. I prefer that you use the javadoc comment style.

/** This method adds a music selection to the playlist.

*

* @param playlistItem       The selection to add to the playList

*/

public void addToPlaylist(MusicSelection playlistItem)

{

// Method definition (i.e., body)

}

Sample run #1 (User correctly creates aplaylist then quits.):

run:

Creating library ...                                                                           /************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 1                                                                                 /************************************************************************************************/ Playlist created!                                                                              /************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3                                                                                 /************************************************************************************************/

Choose an artist.

1) Pink Floyd

2) The Who

3) Led Zeppelin

4) Stephane Grappelli

5) Spyro Gyra

6) Yo-Yo Ma & Friends

7) Yo-Yo Ma & Roma Sinfonietta

Your choice? 3

Choose a title.

1) Kashmir

2) Boogie With Stu

3) Houses of the Holy

Your choice? 1

Your choice "Kashmir" by Led Zeppelin has been added to the playlist.


Selection #1: Genre:       Artist:      Title:       Album:       Release Date:


Rock

Led Zeppelin

Kashmir

Physical Graffiti

1975


/************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3                                                                                 /************************************************************************************************/ Choose an artist.

1) Pink Floyd

2) The Who

3) Led Zeppelin

4) Stephane Grappelli

5) Spyro Gyra

6) Yo-Yo Ma & Friends

7) Yo-Yo Ma & Roma Sinfonietta

Your choice? 2

Choose a title.

1) Pinball Wizard

2) Listening to You / See Me, Feel Me

3) Tommy, Can You Hear Me?

Your choice? 3

Your choice "Tommy, Can You Hear Me?" by The Who has been added to the playlist.

Selection #1:

Genre:       Rock

Artist:      Led Zeppelin

Title:       Kashmir

Album:       Physical Graffiti

Release Date: 1975

Selection #2:

Genre:       Rock

Artist:      The Who

Title:       Tommy, Can You Hear Me?

Album:       Tommy

Release Date: 1969


/************************************************************************************************/

Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3


/************************************************************************************************/ Choose an artist.

1) Pink Floyd

2) The Who

3) Led Zeppelin

4) Stephane Grappelli

5) Spyro Gyra

6) Yo-Yo Ma & Friends

7) Yo-Yo Ma & Roma Sinfonietta

Your choice? 5

Choose a title.

1) Best Friends

2) Heart of the Night

Your choice? 2

Your choice "Heart of the Night" by Spyro Gyra has been added to the playlist.

Selection #1:

Genre:       Rock

Artist:      Led Zeppelin

Title:       Kashmir

Album:       Physical Graffiti

Release Date: 1975

Selection #2:

Genre:       Rock

Artist:      The Who

Title:       Tommy, Can You Hear Me?

Album:       Tommy

Release Date: 1969

Selection #3:

Genre:       Jazz

Artist:      Spyro Gyra

Title:       Heart of the Night

Album:       Road Scholars

Release Date: 1998


/************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 4


/************************************************************************************************/

Displaying current playlist ...

Selection #1:


Genre:

Artist:

Title:

Album:       Release Date:

Selection #2: Genre:       Artist:      Title:       Album:       Release Date:

Selection #3: Genre:       Artist:      Title:       Album:       Release Date:


Rock

Led Zeppelin

Kashmir

Physical Graffiti

1975


Rock

The Who

Tommy, Can You Hear Me?

Tommy

1969


Jazz

Spyro Gyra

Heart of the Night

Road Scholars

1998


Please enter the number of the selection you wish to remove.

Your choice? 2

Selection #2 has been removed from the playlist.



Selection #1: Genre:       Artist:      Title:       Album:       Release Date:

Selection #2: Genre:       Artist:      Title:       Album:       Release Date:


Rock

Led Zeppelin

Kashmir

Physical Graffiti

1975


Jazz

Spyro Gyra

Heart of the Night

Road Scholars

1998



/************************************************************************************************/

Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 2                                                                                 /************************************************************************************************/ Playlist contains entries. Are you sure you want to delete it (Y/N)? Y

Playlist deleted!


/************************************************************************************************/

Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 5                                                                                 /************************************************************************************************/

Thanks for using River's personal music library.

Please visit again soon!

BUILD SUCCESSFUL (total time: 3 minutes 5 seconds)

Sample run #2 (User selects various invalid options then correctly creates aplaylist and quits.):

run:

Creating library ...                                                                           /************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3                                                                                 /************************************************************************************************/ Please create a playlist!                                                                      /************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 1                                                                                 /************************************************************************************************/ Playlist created!                                                                              /************************************************************************************************/

Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3                                                                                 /************************************************************************************************/ Choose an artist.

1) Pink Floyd

2) The Who

3) Led Zeppelin

4) Stephane Grappelli

5) Spyro Gyra

6) Yo-Yo Ma & Friends

7) Yo-Yo Ma & Roma Sinfonietta

Your choice? 8


8 is not a valid choice!

Please enter a number from 1 to 7.

Your choice? 4

Choose a title.

1) As Time Goes By

2) Honeysuckle Rose

3) Sweet Georgia Brown

Your choice? 2

Your choice "Honeysuckle Rose" by Stephane Grappelli has been added to the playlist.



Selection #1: Genre:       Artist:      Title:       Album:       Release Date:


Jazz

Stephane Grappelli

Honeysuckle Rose

Stephane Grappelli in Tokyo

1993



/************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 1                                                                                 /************************************************************************************************/ Playlist already exists!                                                                       /************************************************************************************************/ Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 3                                                                                 /************************************************************************************************/ Choose an artist.

1) Pink Floyd

2) The Who

3) Led Zeppelin

4) Stephane Grappelli

5) Spyro Gyra

6) Yo-Yo Ma & Friends

7) Yo-Yo Ma & Roma Sinfonietta

Your choice? 6


Choose a title.

1) Here Comes the Sun

2) My One and Only Love

3) This Little Light of Mine

Your choice? 3

Your choice "This Little Light of Mine" by Yo-Yo Ma & Friends has been added to the playlist.



Selection #1: Genre:       Artist:      Title:       Album:       Release Date:

Selection #2: Genre:       Artist:      Title:       Album:       Release Date:


Jazz

Stephane Grappelli

Honeysuckle Rose

Stephane Grappelli in Tokyo

1993


Classical Crossover

Yo-Yo Ma & Friends

This Little Light of Mine

Songs of Joy & Peace

2008



/************************************************************************************************/

Welcome to River's personal music library!

Choose an option.

1) Create Playlist

2) Delete Playlist

3) Add Selection to Playlist

4) Remove Selection from Playlist

5) Quit

Your choice? 4                                                                                 /************************************************************************************************/

Displaying current playlist ...

Selection #1:

Genre:       Jazz

Artist:      Stephane Grappelli

Title:       Honeysuckle Rose

Album:       Stephane Grappelli in Tokyo

Release Date: 1993

Selection #2:

Genre:       Classical Crossover

Artist:      Yo-Yo Ma & Friends

Title:       This Little Light of Mine

Album:       Songs of Joy & Peace

Release Date: 2008

Please enter the number of the selection you wish to remove.

Your choice? 3

3 is not a valid choice!

Please enter a number from 1 to 2.

Your choice? 1

Selection #1 has been removed from the playlist.

Selection #1:

Genre:       Classical Crossover

Artist:      Yo-Yo Ma & Friends

Title:       This Little Light of Mine

Album:       Songs of Joy & Peace

Release Date: 2008