File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Interpretor Pattern: Need Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Interpretor Pattern: Need Help" Watch "Interpretor Pattern: Need Help" New topic

Interpretor Pattern: Need Help

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

I'm writing a Java sample program for demonstrating interpretor design Pattern.

Can you please tell me how should i go about writing the "Note class and the Frequency class" for the above example.

How should i invoke the above class from my main method.I'm finding it difficult to proceed.
Need your help ??

Help provided will be appreciated.

Deepak Lal

When The Going Gets Tougher,The Tougher gets Going
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Where do you see the Interpreter design pattern in this example?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

This is an example of Interpretor design pattern.
The musical notes along with their frequencies is stored in the properties file.
By passing a Note,a corresponding frequency is retrieved and based on the frequency a corresponding sound is produced.

Please see the below link for reference.

Can you tell me how should my Note class and Frequency class Look like and how should i write a main method such that it invokes the class. ?

Deepak Lal

I agree. Here's the link:
subject: Interpretor Pattern: Need Help
It's not a secret anymore!