Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Using the code below, In the Driver program create few objects and compare them. Then create a list of those objects and sort them.

1. Using the code below, In the Driver program create few objects and compare them. Then create a list of those objects and sort them.

2. Rewrite the Note class so that a list of Notes is sorted first by length of note and then within that by frequency.

public class NoteTester {

/**

Variables for the value and the length.

*/

private int length;

private int value;

public NoteTester(int len, int val) {

length = len;

value = val;

}

/**

Constructor

the length of the note and the value of the note.

*/

NoteTester() {

this.value = 0;

this.length = 4;

}

/**

Setter for The setLength method and setValue methods.

*/

public void setLength(int len) {

this.length = len;

}

public void setValue(int val) {

this.value = val;

}

/**

The getLength method getValue method.

*/

public int getLength(){

return this.length;

}

public int getValue(){

return this.value;

}

/**

Starting an Array for the note and finding the value of

the note. */

public String findNoteTester(){

String [] notes = {"A","A#",

"B","C","C#","D","D#","E","F","F#","G","G#"};

return notes[(value + 60) % 12];

}

/**

The getFrequency method returns the notes Frequency.

*/

public double getFrequency () {

double frequency = 440 * (Math.pow(2,value/12.0));

return frequency;

}

/////////////////////////////////////////////

public class DriverTest {

public static void main(String[] args) {

// TODO Auto-generated method stub

NoteTester m = new NoteTester(); // note input

m.setValue(20); // the value for the note

m.setLength(20); // the length for the note

String notes = m.findNoteTester();

double Freq = m.getFrequency();

}

}

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

List behaviors to improve effective leadership in meetings

Answered: 1 week ago