Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this task you will extend the implementation of your text-based music player. (please code this in ruby) Provided code: music_player_with_menu.rb require './input_functions' # It

In this task you will extend the implementation of your text-based music player. (please code this in ruby)

image text in transcribed

image text in transcribed

Provided code: music_player_with_menu.rb

require './input_functions'

# It is suggested that you put together code from your

# previous tasks to start this. eg:

# TT3.2 Simple Menu Task

# TT5.1 Music Records

# TT5.2 Track File Handling

# TT6.1 Album file handling

albums.txt: 4 Neil Diamond Greatest Hits 2 3 Crackling Rose sounds/01-Cracklin-rose.wav Soolaimon sounds/06-Soolaimon.wav Sweet Caroline sounds/20-Sweet_Caroline.wav Platters Greatest Hits 1 2 Twilight Time sounds/01-Twilight_Time.wav The Great Pretender sounds/10-The_Great_Pretender.wav Don McClean American Pie 2 0 Carly Simon No Secrets 2 3 The Carter Family sounds/02-The_Carter_Family.wav Your So Vain sounds/03-Youre_So_Vain.wav Embrace me You Child sounds/06-Embrace_Me_You_Child.wav

input_functions.rb:

# Display the prompt and return the read string

def read_string prompt

puts prompt

value = gets.chomp

end

# Display the prompt and return the read float

def read_float prompt

value = read_string(prompt)

value.to_f

end

# Display the prompt and return the read integer

def read_integer prompt

value = read_string(prompt)

value.to_i

end

# Read an integer between min and max, prompting with the string provided

def read_integer_in_range(prompt, min, max)

value = read_integer(prompt)

while (value max)

puts "Please enter a value between " + min.to_s + " and " + max.to_s + ": "

value = read_integer(prompt);

end

value

end

# Display the prompt and return the read Boolean

def read_boolean prompt

value = read_string(prompt)

case value

when 'y', 'yes', 'Yes', 'YES'

true

else

false

end

end

# Test the functions above

=begin

def main

puts "String entered is: " + read_string("Enter a String: ")

puts "Boolean is: " + read_boolean("Enter yes or no:").to_s

puts "Float is: " + read_float("Enter a floating point number: ").to_s

puts "Integer is: " + read_integer_in_range("Enter an integer between 3 and 6: ", 3, 6).to_s

end

main

=end

In this task you will extend the implementation of your text--ased music player. As part of the Pass level 1 requirement, your extended text-based music application must display a menu that offers the user the following options: - Menu option 1: Read in Albums - Menu option 2: Display Albums - Menu option 3: Select an Album to play - Menu option 4: Update an existing Album Menu option 1 should prompt the user to enter a filename of a file that contains the following information: - The number of albums - The first album name - The first artist name - The genre of the album - The number of tracks (up to a maximum of 15) - The name and file location (path) of each track - The album information for the remaining albums. Menu option 2 should allow the user to either display all albums or all albums for a particular genre. The albums should be listed with a unique album number which can be used in Option 3 to select an album to play. The album number should serve the role of a 'primary key' for locating an album. But it is allocated internally by your program, not by the user. Menu option 3 should prompt the user to enter the primary key (or album number) for an album as listed using Menu option 2. If the album is found the program should list all the tracks for the album, along with track numbers. The user should then be prompted to enter a track number. If the track number exists, then the system should display the message 'Playing track' then the track name, ' from album ' then the album name. You may or may not call an external program to play the track, but if not the system should delay for several seconds before returning to the main menu. Menu option 4 should allow the user to enter a unique album number and change its title or genre. The updated album should then be displayed to the user and the user is prompted to press enter to return to the main menu (you do not need to update the file at this level). At this level minimum validation is required. Just make sure your program does not crash if incorrect values are entered and that all fields have an expected value (e.g. Perhaps have a default genre of 'unknown' in case the user enters an incorrect value for genre)

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 Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

1 What are the dimensions used in Hofstedes model of culture?

Answered: 1 week ago