hey
im just having a bit of a problem on reading input from a text file. I know that it is probably something simple but I keep overthinking it.
Here is what I am trying to do:
I'm trying to read in a line of text that contains musical notes. A sample input line is
d3,d4,a4,g4,g5,a4,f#5,a4
Each note is separated by a ',' as you can see however I have to find a way of separating the 'd' and the '3' because they each signify different things. The character symbolizes the note and the number after it signifies an octave number and the # symbolizes whether or not the note is a C sharp or not.
Here is what I have so far:
I want to know if i'm on the right track or even just some sort of basic algorithm if I am wrong. I know its something so simple but I just can't pinpoint the correct algorithm for it.
public Note(String strNote) throws InvalidNoteStringException
{
super(strNote);
UtilityClassIn infile = new UtilityClassIn("sweetchildofmine.txt");
infile.openInFile();
String line = infile.readLineFromFile();
while (line!=null)
{
String [] nextfields = line.split(",");
char note = nextfields[0].charAt(0);
//char number = nextfields[0].charAt(1);
char symbol = nextfields[0].charAt(2);
switch(note)
{
case 'a':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'b':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'c':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'd':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'e':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'f':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
case 'g':
{
char number = nextfields[0].charAt(1);
if(number >= 1 && number <= 9)
{
Thread.sleep(200);
}
}
}
}
}