Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

What four processes make up the ideal Otto cycle?

Answered: 1 week ago

Question

LO 15-5 Explain the various kinds of nonstore retailing.

Answered: 1 week ago

Question

Describe the seven standard parts of a letter.

Answered: 1 week ago

Question

Explain how to develop effective Internet-based messages.

Answered: 1 week ago

Question

Identify the advantages and disadvantages of written messages.

Answered: 1 week ago