Question: Java Programming A musician is producing a catalogue of sheet music (printed music) she has collected over a number of years. She is writing a

Java Programming

A musician is producing a catalogue of sheet music (printed music) she has collected over a number of years. She is writing a java application to help her keep track of the origins and reference numbers she has allocated to each piece of music.

The following is an incomplete class definition to represent a piece of sheet music.

public class SheetMusic

{

private String title;

private String author;

private String reference;

public SheetMusic (String title, String author, String reference)

{

this.title = title;

this.author = author;

this.reference = reference;

}

/ **

* search title for some words, return true

* or false

*/

public boolean titleMatch (String text)

{

// to be completed

}

}

The class SheetMusic records details for a piece of music in the catalogue. The method titleMatch is incomplete.

a) Write appropiate accessor methods for the title, author and reference fields.

b) Complete the body of the titleMatch method. The method should return true if the title of the music contains the text parameter, and false otherwise.

A separate class, Catalogue, will maintain a list of SheetMusic objects together with the name of the person owning the catalogue. The class has been partially written, as follows:

import java.util.ArrayList;

public class Catalogue

{

private String name;

private Arraylist tunes;

// constructor to be completed

public ArrayList

tunesMatching (String text)

{

// return list of tunes with title

// containing text

c) Write a constructor for the Catalogue class. The constructor should have a name initialised using a parameter to the constructor, and the tunes field initialised to an empty list.

d) Write a method, addTune, to add a SheetMusic object to the list of tunes.

e) The tunesMatching method will search all tunes in the list for a title containing the given text, and return an Arraylist of tunes which contain the text in their title.

Complete the body of the tunesMatching method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!