Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java Description: In our earlier programs, the states of the objects we constructed at runtime were lost when the program stopped. For many applications,

In java

image text in transcribed

Description: In our earlier programs, the states of the objects we constructed at runtime were lost when the program stopped. For many applications, this is an unacceptable limitation. A word processor, for instance, wouldn't be very useful if we lost our documents when we turned off our computer. For our third lab, we will write a pair of classes that do not have this limitation: Song and Playlist. Playlist objects store a list of Song objects that can be modified in various ways. Most importantly, the state of a Playlist can be saved and loaded from a text file, so we can keep track of our music collection even after our program stops! Class Diagram: 10..1 0..* Song -title: String -artist: String -minutes: int -seconds: int -numPlays: int - IDX TITLE = 0: int -IDX ARTIST = 1: int -IDX LENGTH = 2: int - IDX NUM PLAYS = 3: int +Song(info: String) +Song (other: Song) +getTitle(): String +getArtist(): String +getMinutes(): int +getSeconds(): int +getLength(): String +getNumPlays(): int +incrementPlays(): void +toString(): String Playlist -songs: ArrayList +Playlist() +Playlist(filename: String) - load(filename: String): void +save(filename: String): void +addSong( song: Song): void +addSong(index: int, song: Song): void +addSongs (filename: String): void +getSong(index: int): Song +numSongs(): int +playSong(index: int): void +remove Song(index: int): Song +toString(): String +favoriteArtist(): String +totalPlaytime(): String Song Class: Each Song has a title, artist, length, and play count. The length is stored in two fields: minutes and seconds. Songs can be constructed from either an info String or another Song object. Info Strings have the following format: ",<artist>,<minutes>:<seconds the numbers on aggregation line indicate that each song belongs to either or playlist. likewise indicates playlist has more songs. description: in our earlier programs states of objects we constructed at runtime were lost when program stopped. for many applications this is an unacceptable limitation. a word processor instance wouldn be very useful if documents turned off computer. third lab will write pair classes do not have limitation: and store list can modified various ways. most importantly state saved loaded from text file so keep track music collection even after stops diagram: string int idx title="0:" artist="1:" length="2:" num plays="3:" void arrayliststyle=""> +Playlist() +Playlist(filename: String) - load(filename: String): void +save(filename: String): void +addSong( song: Song): void +addSong(index: int, song: Song): void +addSongs (filename: String): void +getSong(index: int): Song +numSongs(): int +playSong(index: int): void +remove Song(index: int): Song +toString(): String +favoriteArtist(): String +totalPlaytime(): String Song Class: Each Song has a title, artist, length, and play count. The length is stored in two fields: minutes and seconds. Songs can be constructed from either an info String or another Song object. Info Strings have the following format: "<title>,<artist>,<minutes>:<seconds the numbers on aggregation line indicate that each song belongs to either or playlist. likewise indicates playlist has more songs></seconds></minutes></artist>

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Explain why this is an example of the prisoners dilemma. LO4

Answered: 1 week ago