Dr. Taylor's Support Forums

You are not logged in.

#1 2009-04-09 16:23:28

taylor
Professor
From: Milwaukee, WI
Registered: 2004-08-30
Posts: 266
PM  Website

Lab 5 (Guitar Lab question)

A couple of students asked the following:

So when checking the note file is in the correct format, do we have to check that the name of the note is valid?

Here's my answer:

The getFrequency method from the Note class (which is called by the Note constructor) will throw an IllegalArgumentException if it can't parse the note and the Note constructor will throw the same exception if the duration is negative.

All you need to do is watch for exceptions that could be thrown when the Note is created.  If an exception is thrown, you just ignore that Note (don't add it to the Guitar object), and then continue reading the file.

Offline

 

Board footer

This website is not owned or managed by the Milwaukee School of Engineering.

© 2001-2007 Dr. Christopher C. Taylor, et. al., • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ