Beispiel #1
0
 public bool AddNote(string label, int measureNumber, Note note)
 {
     // find the staff label of interest
     if (staff.ContainsKey(label))
     {
         List <Measure> measures = staff[label];
         if (measureNumber < measures.Count)
         {
             Measure m = measures[measureNumber];
             return(m.AddNote(note));
         }
     }
     return(false);
 }
        public void TestAdditionOfNotes()
        {
            // Create a measure in 3/4 time.
             Measure m = new Measure(new Rational(3, 4));
             Note q = new Note(0, 0, new Rational(1, 4));
             bool ok;
             ok = m.AddNote(q);
             Assert.IsTrue(ok);
             Assert.IsTrue( m.Length().CompareTo(new Rational(1, 4)) == 0 );

             ok = m.AddNote(q);
             Assert.IsTrue(ok);
             Assert.IsTrue( m.Length().CompareTo(new Rational(2, 4)) == 0 );

             ok = m.AddNote(q);
             Assert.IsTrue(ok);
             Assert.IsTrue( m.Length().CompareTo(new Rational(3, 4)) == 0 );

             // This last addition should *not* be ok and should not change the length from 3/4 to anything else.
             ok = m.AddNote(q);
             Assert.IsFalse(ok);
             Assert.IsTrue( m.Length().CompareTo(new Rational(3, 4)) == 0 );
        }
        public void TestAdditionOfNotes()
        {
            // Create a measure in 3/4 time.
            Measure m = new Measure(new Rational(3, 4));
            Note    q = new Note(0, 0, new Rational(1, 4));
            bool    ok;

            ok = m.AddNote(q);
            Assert.IsTrue(ok);
            Assert.IsTrue(m.Length().CompareTo(new Rational(1, 4)) == 0);

            ok = m.AddNote(q);
            Assert.IsTrue(ok);
            Assert.IsTrue(m.Length().CompareTo(new Rational(2, 4)) == 0);

            ok = m.AddNote(q);
            Assert.IsTrue(ok);
            Assert.IsTrue(m.Length().CompareTo(new Rational(3, 4)) == 0);

            // This last addition should *not* be ok and should not change the length from 3/4 to anything else.
            ok = m.AddNote(q);
            Assert.IsFalse(ok);
            Assert.IsTrue(m.Length().CompareTo(new Rational(3, 4)) == 0);
        }