Note that there are some explanatory texts on larger screens.

plurals
  1. POMake a string of letters and numbers?
    text
    copied!<p>I've been wanting to write a music program for a while, but I don't really know that much about programming so that probably won't happen. The goal of this program at first would be to represent guitar chords with letter names (Ex: CMaj = CEG) and there could be a few different types of chords (majors, minors, diminished, etc.) To make this the easiest, I think I'm going to start with a C major scale because in that there are no sharps or flats. My first chord would probably be a C major, which is the 1st, 3rd, and 5th of the scale ( <strong>C</strong> D <strong>E</strong> F <strong>G</strong> A B ). My question is, using strings and characters (or some other way, I'm kind of guessing), is there a way to represent C as String(?) C, where C=1, D=2, E=3,..etc. so that when the program inputs for a major chord, it requests the 1st, 3rd and fifth of the respective scale? So basically the user picks the chord C Maj, which converts to 1, 3, 5, and then the scales are matched up and the program calls those 3 specific intervals of that scale.</p> <p>Any help would be appreciated, or a different way to think about this entirely.</p> <p>Using what little knowledge I've had, I used <a href="http://download.oracle.com/javase/tutorial/java/javaOO/enum.html" rel="nofollow">Oracles</a> website and found their example of enumeration and put this together: </p> <pre><code>public enum Chord { CHORD, MAJOR, MINOR, DIMINISHED, BASS, BASS2 </code></pre> <p>}</p> <pre><code>public enum Scales { C, D, E, F, G, A </code></pre> <p>}</p> <pre><code>public class EnumTest { Chord chord; public EnumTest(Chord chord) { this.chord = chord; } public void tellItLikeItIs() { switch (chord) { case MAJOR: System.out.println("C, E, G"); break; case MINOR: System.out.println("C, Eb, G"); break; default: System.out.println("I screwed up"); break; } } public static void main(String[] args) { EnumTest firstDay = new EnumTest(Chord.MAJOR); firstDay.tellItLikeItIs(); EnumTest thirdDay = new EnumTest(Chord.MINOR); thirdDay.tellItLikeItIs(); } </code></pre> <p>}</p> <p>I still don't understand, using Olivers example, how to specify when I make a C major chord that I want the 1st, 3rd, and 5th value of the Scales enum. I like the idea about using the semi-tones from C and building off each chord, but I couldn't figure out how to put the #s into the Scales class (illegal character).. So basically my question is how do I get the Chord class to get the scale degrees from the Scales class and plug it into the EnumTest class?</p> <p>(If there is somewhere else I can go and ask dumb questions without bugging people I can try asking there =p)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload